about summary refs log tree commit diff
path: root/src/libstd/thread
AgeCommit message (Collapse)AuthorLines
2016-10-22Add Fuchsia supportRaph Levien-30/+42
Adds support for the x86_64-unknown-fuchsia target, which covers the Fuchsia operating system.
2016-10-10Auto merge of #36341 - sagebind:thread_id, r=alexcrichtonbors-0/+59
Add ThreadId for comparing threads This adds the capability to store and compare threads with the current calling thread via a new struct, `std::thread::ThreadId`. Addresses the need outlined in issue #21507. This avoids the need to add any special checks to the existing thread structs and does not rely on the system to provide an identifier for a thread, since it seems that this approach is unreliable and undesirable. Instead, this simply uses a lazily-created, thread-local `usize` whose value is copied from a global atomic counter. The code should be simple enough that it should be as much reliable as the `#[thread_local]` attribute it uses (however much that is). `ThreadId`s can be compared directly for equality and have copy semantics. Also see these other attempts: - rust-lang/rust#29457 - rust-lang/rust#29448 - rust-lang/rust#29447 And this in the RFC repo: rust-lang/rfcs#1435
2016-10-07Unlock guard before overflow panicStephen M. Coakley-0/+1
2016-10-05Use mutex to guard thread ID counterStephen M. Coakley-30/+8
2016-10-05Generate ID using u64 + atomic spinlockStephen M. Coakley-14/+54
2016-09-30Auto merge of #36339 - brson:emscripten-new, r=alexcrichtonbors-2/+2
Working asmjs and wasm targets This patch set results in a working standard library for the asmjs-unknown-emscripten and wasm32-unknown-emscripten targets. It is based on the work of @badboy and @rschulman. It does a few things: - Updates LLVM with the emscripten [fastcomp](https://github.com/rust-lang/llvm/pull/50) patches, which include the pnacl IR legalizer and the asm.js backend. This patch is thought not to have any significant effect on existing targets. - Teaches rustbuild to correctly link C code with emscripten - Updates gcc-rs to work correctly with emscripten - Teaches rustbuild to run crate tests for emscripten with node - Modifies Thread::new to return an error on emscripten, to facilitate debugging a common failure mode - Modifies libtest to run in single-threaded mode for emscripten - Ignores a host of tests that don't work yet, mostly dealing with threads and I/O - Updates libc with wasm32 definitions (presently the same as asmjs) - Adds a wasm32-unknown-emscripten target that feeds the output of LLVM's asmjs backend through emcc to generate wasm Notes and caveats: - This is only known to work with `--enable-rustbuild`. - The wasm32 target can't be tested correctly yet because of issues in compiletest and limitations in node https://github.com/kripken/emscripten/issues/4542, but hello.rs does seem to work when run on node via the binaryen interpreter - This requires an up to date installation of the emscripten sdk from its incoming branch - Unwinding is very broken - When enabling the emscripten targets jemalloc is disabled for all targets, which results in test failures for the host Next steps are to fix the jemalloc issue, start building the two emscripten targets on the auto builders, then start producing nightlies. https://github.com/rust-lang/rust/issues/36317 tracks work on this. Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36515 Fixes https://github.com/rust-lang/rust/issues/36356
2016-09-30Ignore various entire test modules on emscriptenBrian Anderson-27/+2
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+25
2016-09-16Update to new macro url syntaxGuillaume Gomez-1/+1
2016-09-08Fix testsStephen M. Coakley-2/+2
2016-09-07Add ThreadId for comparing threadsStephen M. Coakley-0/+40
2016-09-04Clean up thread-local storage docsAndrew Paseltiner-20/+15
`std` no longer contains an implementation of scoped TLS.
2016-08-30Rollup merge of #35997 - matthew-piziak:thread-current-example, r=GuillaumeGomezGuillaume Gomez-0/+18
add a simple example for `thread::current()` r? @GuillaumeGomez
2016-08-25add a simple example for `thread::current()`Matthew Piziak-0/+18
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-13/+0
2016-08-03Add link to replacement functionStefan Schindler-1/+6
2016-08-03Add an example to `std::thread::park_timeout`Stefan Schindler-0/+19
2016-06-28Rollup merge of #34406 - frewsxcv:sleep-ex, r=alexcrichtonGuillaume Gomez-0/+13
Add example for `std::thread::sleep`. None
2016-06-27Add example for `std::thread::sleep`.Corey Farwell-0/+13
2016-06-25Auto merge of #34465 - frewsxcv:builder-name-example, r=GuillaumeGomezbors-0/+15
Add doc example for `std::thread::Builder::name`. None
2016-06-25Auto merge of #34410 - frewsxcv:code-like, r=apasel422bors-4/+4
Parameters in doc comment should be formatted code-like. None
2016-06-25Rollup merge of #34438 - frewsxcv:joinhandle, r=GuillaumeGomezManish Goregaokar-0/+30
Indicate how the `JoinHandle` struct is created. None
2016-06-25Add doc example for `std::thread::Builder::name`.Corey Farwell-0/+15
2016-06-24Add examples in docs for `JoinHandle`.Corey Farwell-0/+24
2016-06-24Use `Option::expect` instead of `unwrap_or_else` with `panic!`.Corey Farwell-3/+3
2016-06-24Indicate how the `JoinHandle` struct is created.Corey Farwell-0/+6
2016-06-23Auto merge of #34077 - durka:patch-23, r=alexcrichtonbors-4/+38
upgrade thread_local! invocation syntax Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items. In particular, `#![forbid(missing_docs, unused)]` is now tenable on a crate/module containing thread locals. For an example see [here](https://is.gd/aVFZZF). This change is fully backwards compatible as far as I can tell. cc @frankmcsherry
2016-06-22upgrade thread_local! invocation syntaxAlex Burka-4/+38
Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items.
2016-06-22Parameters in doc comment should be formatted code-like.Corey Farwell-4/+4
2016-06-21Rollup merge of #34371 - frewsxcv:thread-name, r=steveklabnikGuillaume Gomez-0/+31
Add examples for `std::thread::Thread::name`. None
2016-06-19Add examples for `std::thread::Thread::name`.Corey Farwell-0/+31
2016-06-18Add example in docs for `std::thread::panicking`.Corey Farwell-0/+29
2016-05-30std: Clean out old unstable + deprecated APIsAlex Crichton-308/+0
These should all have been deprecated for at least one cycle, so this commit cleans them all out.
2016-05-16Added a big-picture explanation for thread::park() & co.Pyry Kontio-1/+3
2016-05-09rustc: Implement custom panic runtimesAlex Crichton-11/+6
This commit is an implementation of [RFC 1513] which allows applications to alter the behavior of panics at compile time. A new compiler flag, `-C panic`, is added and accepts the values `unwind` or `panic`, with the default being `unwind`. This model affects how code is generated for the local crate, skipping generation of landing pads with `-C panic=abort`. [RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md Panic implementations are then provided by crates tagged with `#![panic_runtime]` and lazily required by crates with `#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic runtime must match the final product, and if the panic strategy is not `abort` then the entire DAG must have the same panic strategy. With the `-C panic=abort` strategy, users can expect a stable method to disable generation of landing pads, improving optimization in niche scenarios, decreasing compile time, and decreasing output binary size. With the `-C panic=unwind` strategy users can expect the existing ability to isolate failure in Rust code from the outside world. Organizationally, this commit dismantles the `sys_common::unwind` module in favor of some bits moving part of it to `libpanic_unwind` and the rest into the `panicking` module in libstd. The custom panic runtime support is pretty similar to the custom allocator support with the only major difference being how the panic runtime is injected (takes the `-C panic` flag into account).
2016-05-02std::thread docs: spawn() returns not a Thread anymoreGeorg Brandl-15/+14
Also move the "Thread type" section down a bit, since it is not so important anymore. Fixes: #33321
2016-04-25libstd: fix typos in thread::LocalKey docsRyman-2/+2
2016-03-25Fix unsound behaviour with null characters in thread names (issue #32475)David Henningsson-3/+18
Previously, the thread name (&str) was converted to a CString in the new thread, but outside unwind::try, causing a panic to continue into FFI. This patch changes that behaviour, so that the panic instead happens in the parent thread (where panic infrastructure is properly set up), not the new thread. This could potentially be a breaking change for architectures who don't support thread names. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-03-22try! -> ?Jorge Aparicio-1/+1
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-12std: Clean out deprecated APIsAlex Crichton-34/+0
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-04End stdlib module summaries with a full stop.Steve Klabnik-1/+1
Fixes #9447
2016-02-29std: Stabilize APIs for the 1.8 releaseAlex Crichton-0/+10
This commit is the result of the FCPs ending for the 1.8 release cycle for both the libs and the lang suteams. The full list of changes are: Stabilized * `braced_empty_structs` * `augmented_assignments` * `str::encode_utf16` - renamed from `utf16_units` * `str::EncodeUtf16` - renamed from `Utf16Units` * `Ref::map` * `RefMut::map` * `ptr::drop_in_place` * `time::Instant` * `time::SystemTime` * `{Instant,SystemTime}::now` * `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier` * `{Instant,SystemTime}::elapsed` * Various `Add`/`Sub` impls for `Time` and `SystemTime` * `SystemTimeError` * `SystemTimeError::duration` * Various impls for `SystemTimeError` * `UNIX_EPOCH` * `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign` Deprecated * Scoped TLS (the `scoped_thread_local!` macro) * `Ref::filter_map` * `RefMut::filter_map` * `RwLockReadGuard::map` * `RwLockWriteGuard::map` * `Condvar::wait_timeout_with` Closes #27714 Closes #27715 Closes #27746 Closes #27748 Closes #27908 Closes #29866
2016-02-04Stop using unsafe code in TLS macro expansion (fixes #30756)Manish Goregaokar-23/+27
2016-01-29std: Ignore dtors_in_dtors_in_dtors on OSXAlex Crichton-0/+25
This test has been deadlocking and causing problems on the bots basically since its inception. Some memory safety issues were fixed in 987dc84b, but the deadlocks remained afterwards unfortunately. After some investigation, I've concluded that this is just a situation where OSX is not guaranteed to run destructors. The fix in 987dc84b observed that OSX was rewriting the backing TLS memory to its initial state during destruction while we weren't looking, and this would have the effect of canceling the destructors of any other initialized TLS slots. While very difficult to pin down, this is basically what I assume is happening here, so there doesn't seem to really be anythig we can do to ensure the test robustly passes on OSX, so just ignore it for now.
2016-01-11Replace no_elf_tls with target_thread_localAmanieu d'Antras-38/+3
2015-12-29Fix warnings when compiling stdlib with --testFlorian Hahn-5/+5
2015-12-21std: Use cfg(target_thread_local) in thread_local!Alex Crichton-77/+48
This transitions the standard library's `thread_local!` macro to use the freshly-added and gated `#[cfg(target_thread_local)]` attribute. This greatly simplifies the `#[cfg]` logic in play here, but requires that the standard library expose both the OS and ELF TLS implementation modules as unstable implementation details. The implementation details were shuffled around a bit but end up generally compiling to the same thing. Closes #26581 (this supersedes the need for the option) Closes #27057 (this also starts ignoring the option)
2015-12-10Auto merge of #30267 - alexcrichton:tls-init-oh-my, r=nikomatsakisbors-1/+16
Due to #30228 it's not currently sound to do `*ptr = Some(value)`, so instead use `mem::replace` which fixes the soundness hole for now.
2015-12-09std: Rename thread::catch_panic to panic::recoverAlex Crichton-18/+1
This commit is an implementation of [RFC 1236] and [RFC 1323] which rename the `thread::catch_panic` function to `panic::recover` while also replacing the `Send + 'static` bounds with a new `PanicSafe` bound. [RFC 1236]: https://github.com/rust-lang/rfcs/pull/1236 [RFC 1323]: https://github.com/rust-lang/rfcs/pull/1323 cc #27719
2015-12-08std: Use mem::replace in TLS initializationAlex Crichton-1/+16
Due to #30228 it's not currently sound to do `*ptr = Some(value)`, so instead use `mem::replace` which fixes the soundness hole for now.