about summary refs log tree commit diff
path: root/src/libstd/thread
AgeCommit message (Collapse)AuthorLines
2018-08-06clarify partially initialized Mutex issuesRalf Jung-0/+3
2018-08-01Rollup merge of #52771 - matklad:patch-1, r=kennytmPietro Albini-1/+4
Clarify thread::park semantics It took me quite some time to realize that the example is not actually racy, so let's clarify it? :-)
2018-07-28Rollup merge of #52759 - stjepang:impl-send-sync-for-joinhandle, r=TimNNkennytm-0/+5
Impl Send & Sync for JoinHandle This is just a cosmetic change - it slightly relaxes and clarifies the public API without effectively promising any new guarantees. Currently we have [these auto trait implementations](https://doc.rust-lang.org/nightly/std/thread/struct.JoinHandle.html#synthetic-implementations): ```rust impl<T: Send> Send for JoinHandle<T> {} impl<T: Sync> Sync for JoinHandle<T> {} ``` Bound `T: Send` doesn't make much sense because `JoinHandle<T>` can be created only when `T: Send`. Note that [`JoinHandle::<T>::join`](https://doc.rust-lang.org/nightly/std/thread/struct.JoinHandle.html#method.join) doesn't require `T: Send` so why should the `Send` impl? And the `Sync` impl doesn't need `T: Sync` because `JoinHandle<T>` cannot even share `T` - it can only send it to the thread that calls `join`.
2018-07-27Fix wsAleksey Kladov-1/+1
2018-07-27Clarify thread::park semanticsAleksey Kladov-1/+4
2018-07-27Add stability attributesStjepan Glavina-0/+2
2018-07-27Impl Send & Sync for JoinHandleStjepan Glavina-0/+3
2018-07-11Add missing dyn in testsljedrz-4/+4
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-1/+1
2018-06-29Auto merge of #51290 - Pslydhh:master, r=alexcrichtonbors-2/+8
park/park_timeout: prohibit spurious wakeups in next park <pre><code> // The implementation currently uses the trivial strategy of a Mutex+Condvar // with wakeup flag, which does not actually allow spurious wakeups. </pre></code> Because does not actually allow spurious wakeups. so we have let thread.inner.cvar.wait(m) in the loop to prohibit spurious wakeups. but if notified after we locked, this notification doesn't be consumed, it return, the next park will consume this notification...this is also 'spurious wakeup' case, 'one unpark() wakeups two park()'. We should improve this situation: `thread.inner.state.store(EMPTY, SeqCst);`
2018-06-27Fix the error reference for LocalKey::try_withMichal 'vorner' Vaner-1/+1
2018-06-17libstd: add an RAII utility for sys_common::mutex::MutexNODA, Kai-4/+1
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2018-06-02removes tabsPslydhh-8/+6
2018-06-02remove trailing whitespacePslydhh-6/+6
remove trailing whitespace
2018-06-02park():prohibit spurious wakeups in next parkPslydhh-2/+10
should consume this notification, so prohibit spurious wakeups in next park
2018-04-13std: Minimize size of panicking on wasmAlex Crichton-2/+42
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-03-01Fix a bug introduced in previous commitStjepan Glavina-6/+3
2018-02-28Remove thread_local_stateStjepan Glavina-107/+7
2018-02-28Stabilize LocalKey::try_withStjepan Glavina-14/+19
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-27Auto merge of #45285 - alexcrichton:update-bootstrap, r=Mark-Simulacrumbors-5/+0
Bump to 1.23 and update bootstrap This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-5/+0
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
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-17Docs: a LocalKey might start in the Valid stateStjepan Glavina-1/+4
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-14Auto merge of #43972 - TobiasSchaffner:std_clean, r=alexcrichtonbors-2/+2
Add the libstd-modifications needed for the L4Re target This commit adds the needed modifications to compile the std crate for the L4 Runtime environment (L4Re). A target for the L4Re was introduced in commit: c151220a84e40b65e45308cc0f3bbea4466d3acf In many aspects implementations for linux also apply for the L4Re microkernel. Some uncommon characteristics had to be resolved: * L4Re has no network funktionality * L4Re has a maximum stacksize of 1Mb for threads * L4Re has no uid or gid Co-authored-by: Sebastian Humenda <sebastian.humenda@tu-dresden.de>
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-09-07std::thread::LocalKey: Document limitation with initializersJoshua Liebow-Feeser-0/+4
2017-09-04Make the LocalKey facade of thread_local! inlineable cross-crate.Eduard-Mihai Burtescu-3/+13
2017-08-31Update bootstrap compilerAlex Crichton-4/+1
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
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-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-1/+1
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-2/+2
Like #43008 (f668999), but _much more aggressive_.
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-12Auto merge of #43746 - eddyb:sound-thread-local, r=alexcrichtonbors-31/+31
Check #[thread_local] statics correctly in the compiler. Fixes #43733 by introducing `#[allow_internal_unsafe]` analogous to `#[allow_internal_unstable]`, for letting a macro expand to `unsafe` blocks and functions even in `#![forbid(unsafe_code)]` crates. Fixes #17954 by not letting references to `#[thread_local]` statics escape the function they're taken in - we can't just use a magical lifetime because Rust has *lifetime parametrism*, so if we added the often-proposed `'thread` lifetime, we'd have no way to check it in generic code. To avoid potential edge cases in the compiler, the lifetime is actually that of a temporary at the same position, i.e. `&TLS_STATIC` has the same lifetime `&non_const_fn()` would. Referring to `#[thread_local]` `static`s at compile-time is banned now (as per PR discussion). Additionally, to remove `unsafe impl Sync` from `std::thread::local::fast::Key`, `#[thread_local]` statics are now not required to implement `Sync`, as they are not shared between threads.
2017-08-12Check #[thread_local] statics correctly in the compiler.Eduard-Mihai Burtescu-31/+31
2017-08-11Fix some typosBastien Orivel-1/+1
2017-08-02Indicate how `ThreadId` is created.Corey Farwell-1/+5