about summary refs log tree commit diff
path: root/src/libstd/thread
AgeCommit message (Collapse)AuthorLines
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-22std: Audit std::thread implementationsAlex Crichton-66/+55
Much of this code hasn't been updated in quite some time and this commit does a small audit of the functionality: * Implementation functions now centralize all functionality on a locally defined `Thread` type. * The `detach` method has been removed in favor of a `Drop` implementation. This notably fixes leaking thread handles on Windows. * The `Thread` structure is now appropriately annotated with `Send` and `Sync` automatically on Windows and in a custom fashion on Unix. * The unsafety of creating a thread has been pushed out to the right boundaries now. Closes #24442
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-16/+0
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-15std: Fix thread_local! in non-PIE binariesAlex Crichton-1/+1
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes #24445
2015-04-14rollup merge of #24385: aturon/unstable-scopedAlex Crichton-14/+41
Conflicts: src/libstd/thread/mod.rs src/test/bench/shootout-mandelbrot.rs src/test/bench/shootout-reverse-complement.rs src/test/run-pass/capturing-logging.rs src/test/run-pass/issue-9396.rs src/test/run-pass/tcp-accept-stress.rs src/test/run-pass/tcp-connect-timeouts.rs src/test/run-pass/tempfile.rs
2015-04-14rollup merge of #24377: apasel422/docsAlex Crichton-21/+21
Conflicts: src/libstd/net/ip.rs src/libstd/sys/unix/fs.rs src/libstd/sys/unix/mod.rs src/libstd/sys/windows/mod.rs
2015-04-14test: Fixup many library unit testsAlex Crichton-4/+1
2015-04-14Fallout: move from scoped to spawnAaron Turon-0/+1
2015-04-13Generalize `spawn` beyond unit closuresAaron Turon-10/+32
`thread::spawn` was previously restricted to closures that return `()`, which limited the utility of joining on a spawned thread. However, there is no reason for this restriction, and this commit allows arbitrary return types. Since it introduces a type parameter to `JoinHandle`, it's technically a: [breaking-change] However, no code is actually expected to break.
2015-04-13De-stabilize `thread::scoped` and friendsAaron Turon-4/+8
Issue #24292 demonstrates that the `scoped` API as currently offered can be memory-unsafe: the `JoinGuard` can be moved into a context that will fail to execute destructors prior to the stack frame being popped (for example, by creating an `Rc` cycle). This commit reverts the APIs to `unstable` status while a long-term solution is worked out. (There are several possible ways to address this issue; it's not a fundamental problem with the `scoped` idea, but rather an indication that Rust doesn't currently provide a good way to ensure that destructors are run within a particular stack frame.) [breaking-change]
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-21/+21
2015-04-12std: Work around a stability bug in threadAlex Crichton-3/+3
Make sure the unstable `scoped` modules isn't named the same as the `scoped` function. cc #24334
2015-04-11Rollup merge of #24283 - apasel422:patch-2, r=alexcrichtonManish Goregaokar-2/+2
2015-04-10s/Panicks/Panics/Andrew Paseltiner-2/+2
2015-04-07std: Reorganize thread::local a bitAlex Crichton-28/+26
Make the structure more amenable to what rustdoc is expecting to ensure that everything renders all nice and pretty in the output. Closes #23705 Closes #23910
2015-04-07std: Deny most warnings in doctestsAlex Crichton-0/+1
Allow a few specific ones but otherwise this helps ensure that our examples are squeaky clean! Closes #18199
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-1/+1
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01rollup merge of #23949: aturon/stab-timeoutAlex Crichton-9/+23
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change] r? @alexcrichton cc @sfackler @carllerche
2015-04-01Stabilize basic timeout functionalityAaron Turon-9/+23
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change]
2015-04-01Remove `Thunk` struct and `Invoke` trait; change `Thunk` to be an aliasNiko Matsakis-12/+16
for `Box<FnBox()>`. I found the alias was still handy because it is shorter than the fully written type. This is a [breaking-change]: convert code using `Invoke` to use `FnBox`, which is usually pretty straight-forward. Code using thunk mostly works if you change `Thunk::new => Box::new` and `foo.invoke(arg)` to `foo(arg)`.
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-1/+1
2015-03-31rollup merge of #23873: alexcrichton/remove-deprecatedAlex Crichton-108/+2
Conflicts: src/libcollectionstest/fmt.rs src/libcollectionstest/lib.rs src/libcollectionstest/str.rs src/libcore/error.rs src/libstd/fs.rs src/libstd/io/cursor.rs src/libstd/os.rs src/libstd/process.rs src/libtest/lib.rs src/test/run-pass-fulldeps/compiler-calls.rs
2015-03-31std: Clean out #[deprecated] APIsAlex Crichton-108/+2
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
2015-03-30std: Stabilize the rest of Any/BoxAnyAlex Crichton-1/+0
This commit stabilizes the following APIs: * `TypeId::of` - now that it has an `Any` bound it's ready to be stable. * `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these inherent methods. This is a breaking change due to the removal of the `BoxAny` trait, but consumers can simply remove imports to fix crates. [breaking-change]
2015-03-27rollup merge of #23752: alexcrichton/remove-should-failAlex Crichton-2/+2
This attribute has been deprecated in favor of #[should_panic]. This also updates rustdoc to no longer accept the `should_fail` directive and instead renames it to `should_panic`.
2015-03-27rollup merge of #23651: alexcrichton/unwind-tryAlex Crichton-0/+49
This commit provides a safe, but unstable interface for the `try` functionality of running a closure and determining whether it panicked or not. There are two primary reasons that this function was previously marked `unsafe`: 1. A vanilla version of this function exposes the problem of exception safety by allowing a bare try/catch in the language. It is not clear whether this concern should be directly tied to `unsafe` in Rust at the API level. At this time, however, the bounds on `ffi::try` require the closure to be both `'static` and `Send` (mirroring those of `thread::spawn`). It may be possible to relax the bounds in the future, but for now it's the level of safety that we're willing to commit to. 2. Panicking while panicking will leak resources by not running destructors. Because panicking is still controlled by the standard library, safeguards remain in place to prevent this from happening. The new API is now called `catch_panic` and is marked as `#[unstable]` for now.
2015-03-26syntax: Remove support for #[should_fail]Alex Crichton-2/+2
This attribute has been deprecated in favor of #[should_panic]. This also updates rustdoc to no longer accept the `should_fail` directive and instead renames it to `should_panic`.
2015-03-24rollup merge of #23638: pnkfelix/fsk-reject-specialized-dropsAlex Crichton-1/+1
Reject specialized Drop impls. See Issue #8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Fix #8142 Fix #23584
2015-03-24std: Reexport std::rt::unwind::try in std::threadAlex Crichton-0/+49
This commit provides a safe, but unstable interface for the `try` functionality of running a closure and determining whether it panicked or not. There are two primary reasons that this function was previously marked `unsafe`: 1. A vanilla version of this function exposes the problem of exception safety by allowing a bare try/catch in the language. It is not clear whether this concern should be directly tied to `unsafe` in Rust at the API level. At this time, however, the bounds on `ffi::try` require the closure to be both `'static` and `Send` (mirroring those of `thread::spawn`). It may be possible to relax the bounds in the future, but for now it's the level of safety that we're willing to commit to. 2. Panicking while panicking will leak resources by not running destructors. Because panicking is still controlled by the standard library, safeguards remain in place to prevent this from happening. The new API is now called `catch_panic` and is marked as `#[unstable]` for now.
2015-03-25Bug fixesNick Cameron-0/+1
2015-03-24Added `T:Send` bound to `JoinGuard<T>` to avoid specialized `Drop` impl.Felix S. Klock II-1/+1
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-3/+3
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-0/+3
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23rollup merge of #23601: nikomatsakis/by-value-indexAlex Crichton-1/+1
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`. r? @japaric cc @aturon @Gankro
2015-03-23rollup merge of #23579: Ms2ger/thread_local-unsafeAlex Crichton-5/+3
Conflicts: src/libstd/thread/local.rs
2015-03-23Implement RFC 909: move thread_local into threadAaron Turon-0/+2078
This commit implements [RFC 909](https://github.com/rust-lang/rfcs/pull/909): The `std::thread_local` module is now deprecated, and its contents are available directly in `std::thread` as `LocalKey`, `LocalKeyState`, and `ScopedKey`. The macros remain exactly as they were, which means little if any code should break. Nevertheless, this is technically a: [breaking-change] Closes #23547