summary refs log tree commit diff
path: root/src/libstd/thread/mod.rs
AgeCommit message (Collapse)AuthorLines
2018-04-13std: Minimize size of panicking on wasmAlex Crichton-0/+3
This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-02-28Remove thread_local_stateStjepan Glavina-3/+0
2018-02-28Stabilize LocalKey::try_withStjepan Glavina-1/+4
2018-02-17Unify 'Platform-specific behavior' documentation headings.Corey Farwell-3/+3
2017-11-02Make join a link to the function's documentationSebastian Dröge-1/+1
2017-11-02Mention that panics can't possibly be caught when compiling with panic=abortSebastian Dröge-1/+1
2017-11-02Use ` instead of ' for function namesSebastian Dröge-2/+2
2017-11-02Update the std::thread docs and clarify that panics can nowadays be caughtSebastian Dröge-5/+9
2017-10-25std: Optimize thread park/unpark implementationAlex Crichton-15/+72
This is an adaptation of alexcrichton/futures-rs#597 for the standard library. The goal here is to avoid locking a mutex on the "fast path" for thread park/unpark where you're waking up a thread that isn't sleeping or otherwise trying to park a thread that's already been notified. Mutex performance varies quite a bit across platforms so this should provide a nice consistent speed boost for the fast path of these functions.
2017-10-08Don't encourage people to ignore threading errors in the docsJake Goulding-5/+7
2017-09-18Rollup merge of #44651 - bluss:document-thread-name-no-nuls, r=steveklabnikAlex Crichton-0/+7
Document thread builder panics for nul bytes in thread names This seems to have been undocumented. Mention this where the name is set (Builder::name) and where the panic could happen (Builder::spawn). Thread::new is private and I think the builder is the only user where this matters. A short comment was added to "document" Thread::new too.
2017-09-17std: Document thread builder panics for nul bytes in thread namesUlrik Sverdrup-0/+7
This seems to have been undocumented. Mention this where the name is set (Builder::name) and where the panic could happen (Builder::spawn). Thread::new is private and I think the builder is the only user where this matters. A short comment was added to "document" Thread::new too.
2017-09-13Move default stack min size to thread implementationsTobias Schaffner-2/+2
The default min stack size value is smaller on l4re and therefore this value has to be different depending on the platform.
2017-08-27Auto merge of #44112 - alexcrichton:thread-join, r=sfacklerbors-0/+5
std: Handle OS errors when joining threads Also add to the documentation that the `join` method can panic. cc #34971 cc #43539
2017-08-26std: Handle OS errors when joining threadsAlex Crichton-0/+5
Also add to the documentation that the `join` method can panic. cc #34971 cc #43539
2017-08-24Fix inconsistent doc headingslukaramu-1/+1
This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574.
2017-08-22Thread spawning: don't run `min_stack` if the user has specified stack size.Corey Farwell-1/+1
2017-08-15Fix typos & us spellingsFourchaux-1/+1
2017-08-14Indicate which stack size option has precedence.Corey Farwell-1/+1
2017-08-13Indicate thread names get passed to the OS.Corey Farwell-4/+8
2017-08-13Rewrite docs for stack size/thread names for spawned threads.Corey Farwell-10/+41
* Moves docs about stack size and thread naming from `Builder` to the `std::thread` module * Adds more links to the new module-level documentation * Mentions the 2 MiB stack size default, but indicate it's subject to change Fixes https://github.com/rust-lang/rust/issues/43805.
2017-08-11Fix some typosBastien Orivel-1/+1
2017-08-02Indicate how `ThreadId` is created.Corey Farwell-1/+5
2017-08-02Fix broken links in `Thread` docs.Corey Farwell-0/+3
2017-07-26Rollup merge of #43456 - joshlf:spawn-doc-grammar, r=alexcrichtonMark Simulacrum-1/+1
std::thread::spawn: Fix grammar in documentation Closes #43435.
2017-07-24std::thread::spawn: Fix grammar in documentationJoshua Liebow-Feeser-1/+1
2017-07-23Fix some doc/comment typos.Bruce Mitchener-4/+4
2017-07-11Fix @alexcrichton commentsLee Bousfield-1/+1
2017-06-24Stabilize ThreadIdSteven Fackler-8/+2
Closes #21507
2017-06-23rustc: Enable #[thread_local] for WindowsAlex Crichton-1/+1
I think LLVM has had support for quite some time now for this, we just never got around to testing it out and binding it. We've had some trouble landing this in the past I believe, but it's time to try again! This commit flags the `#[thread_local]` attribute as being available for Windows targets and adds an implementation of `register_dtor` in the `thread::local` module to ensure we can destroy these keys. The same functionality is implemented in clang via a function called `__tlregdtor` (presumably provided in some Windows runtime somewhere), but this function unfortunately does not take a data pointer (just a thunk) which means we can't easily call it. For now destructors are just run in the same way the Linux fallback is implemented, which is just keeping track via a single OS-based TLS key.
2017-06-12Capture elapsed duration in Thread::park_timeout exampleMark Buer-5/+9
2017-06-02Rollup merge of #41981 - gamazeps:thread-detach, r=frewsxcvMark Simulacrum-3/+28
[Doc] Expands `detach` documentation in `thread::JoinHande`. Part of #29378 . - Adds an example of a thread detaching. - Expands what `detaching` means. r? @steveklabnik
2017-06-02Expands `detach` documentation in `thread::JoinHande`.Felix Raimundo-3/+28
Part of #29378 . - Adds an example of a thread detaching. - Expands what `detaching` means.
2017-05-24Rollup merge of #42141 - ids1024:nobacktrace, r=aturonMark Simulacrum-0/+3
Fix building std without backtrace feature, which was broken in ca8b754 Fixes #42139
2017-05-24Rollup merge of #41980 - gamazeps:thread-send, r=steveklabnikMark Simulacrum-0/+22
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of #29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
2017-05-21Fix building without backtrace feature, which was broken in ca8b754Ian Douglas Scott-0/+3
Fixes #42139
2017-05-16Rollup merge of #41994 - gamazeps:thread-builder, r=GuillaumeGomezMark Simulacrum-11/+38
[Doc] Implrove `thread::Builder`'s doc. Part of #29378 . - Explains *why* we would use the builder instead ofthe free function. - Changes the parent-child explanation for a spawned-caller in `thread::Builder::spawn` - Adds a link to `io::Result` in `thread::Builder` - Corrects the return type doc in `thread::Builder::spawn` r? @rust-lang/docs
2017-05-14Improve `thread::Builder` documentation.Felix Raimundo-11/+38
Part of #29378 . - In particular explains *why* we would use the builder instead of the free function. - Changes the parent-child explanation for a spawned-caller. - Add link to `io::Result` in `thread::Builder` - Corrects the `thread::Builder::spawn` documentation.
2017-05-14Add `'static` and `Send` constraints explanations to `thread::spawn`Felix Raimundo-0/+22
Part of #29378.
2017-05-14Explain why `thread::yield_now` could be used.Felix Raimundo-0/+23
Part of #29378.
2017-05-12Rollup merge of #41896 - tshepang:too-long, r=steveklabnikMark Simulacrum-2/+2
doc: break into 2 sentences
2017-05-11doc: break into 2 sentencesTshepang Lekhonkhobe-2/+2
2017-05-10Rollup merge of #41854 - gamazeps:thread-spawn-doc, r=steveklabnikSteve Klabnik-6/+56
[Doc] Improve `thread::spawn` documentation Part of #29378 - Add two examples to `thread::spawn` doumentation that show common uses of threads. - Add a link to `thread::Builder` in the `thread::spawn` documentation for configuring threads. - Add a link to `thread::spawn` in `thread::Builder` in order to avoid documentation duplication. r? @steveklabnik
2017-05-10Rollup merge of #41809 - gamazeps:thread-docs, r=steveklabnikSteve Klabnik-61/+91
[DOC] Improve the thread::park and thread::unpark documentation Part of #29378 . Takes care of the documentation for `park`, `park_duration` and also improves the `unpark` example. - `park should` have its module documentation inlined here, and cleaned up. - `park_timeout` could use links to `park`.
2017-05-10Auto merge of #41815 - Yamakaky:improve-backtrace-bottom, r=alexcrichtonbors-1/+3
Improve cleaning of the bottom of the backtrace Following https://github.com/rust-lang/rust/pull/40264. It only cleans the bottom of the trace (after the main). It handles correctly the normal main, tests, benchmarks and threads. I kept `skipped_before` since it will be used later for the cleaning of the top.
2017-05-10Fix typos in docFelix Raimundo-1/+1
2017-05-09Don't show the std frames before user code on unwinding.Yamakaky-1/+3
When `RUST_BACKTRACE=1`, remove all frames after `__rust_maybe_catch_panic`. Tested on `main`, threads, tests and benches. Cleaning of the top of the stacktrace is let to a future PR. Fixes #40201 See #41815
2017-05-09Fix warnings in examplesFelix Raimundo-4/+4
2017-05-09Fix linkFelix Raimundo-5/+5
2017-05-09Auto merge of #41814 - gamazeps:thread-struct-doc, r=steveklabnikbors-23/+20
[Doc] improve `thread::Thread` and `thread::Builder` documentations Part of #29378 - Adds information about the stack_size when using `Builder`. This might be considered too low level, but I assume that if someone wants to create their own builder instead of using `thread::spawn` they may be interested in that info. - Updates the `thread::Thread` structure doc, mostly by explaining how to get one, the previous example was removed because it was not related to `thread::Thread`, but rather to `thread::Builder::name`. Not much is present there, mostly because this API is not often used (the only method that seems useful is `unpark`, which is documented in #41809).