about summary refs log tree commit diff
path: root/src/libstd/thread/mod.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1787/+0
2020-07-16Rollup merge of #73269 - mzohreva:mz/sgx-wait-timeout, r=jethrogbManish Goregaokar-3/+0
Enable some timeouts in SGX platform This would partially resolve https://github.com/fortanix/rust-sgx/issues/31 cc @jethrogb and @Goirad
2020-07-12Remove the useless indentationLzu Tao-3/+2
2020-06-12Enable some timeouts in SGX platformMohsen Zohrevandi-3/+0
This would partially resolve https://github.com/fortanix/rust-sgx/issues/31
2020-06-10Migrate to numeric associated constsLzu Tao-1/+0
2020-05-12Warn against thread::sleep in async fnKornel-0/+4
2020-05-11Fix clippy warningsMatthias Krüger-1/+1
Fixes clippy::{cone_on_copy, filter_next, redundant_closure, single_char_pattern, len_zero,redundant_field_names, useless_format, identity_conversion, map_clone, into_iter_on_ref, needless_return, option_as_ref_deref, unused_unit, unnecessary_mut_passed}
2020-04-20Stop accessing module level int consts via crate::<Ty>Linus Färnstrand-1/+1
2020-03-21Return NonZeroU64 from ThreadId::as_u64.Thomas Bächler-2/+2
As discussed in #67939, this allows turning Option<ThreadId> into Option<NonZeroU64> which can then be stored inside an AtomicU64.
2020-01-06Add an unstable conversion from thread ID to u64Mark Rousskov-0/+13
We see multiple cases inside rustc and ecosystem code where ThreadId is transmuted to u64, exploiting the underlying detail. This is suboptimal (can break unexpectedly if we change things in std). It is unlikely that ThreadId will ever need to be larger than u64 -- creating even 2^32 threads over the course of a program is quite hard, 2^64 is even harder. As such, we do not choose to return a larger sized type (e.g. u128). If we choose to shrink ThreadId in the future, or otherwise change its internals, it is likely that a mapping to u64 will still be applicable (though may become more complex).
2019-12-22Format the worldMark Rousskov-80/+99
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-3/+3
2019-11-07Try with crate::error::ErrorPyry Kontio-1/+1
2019-11-06Fix the Error linking.Pyry Kontio-1/+1
2019-11-06Addressed review comments.Pyry Kontio-6/+6
2019-11-05Improve std::thread::Result documentationPyry Kontio-0/+12
2019-09-25std: Reduce checks for `feature = "backtrace"`Alex Crichton-3/+0
This is a stylistic change to libstd to reduce the number of checks of `feature = "backtrace"` now that we unconditionally depend on the `backtrace` crate and rely on it having an empty implementation. otherwise.
2019-07-27Remove run-pass test suitesVadim Petrochenkov-1/+1
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+1
2019-04-18Use more realistic example for thread builderAleksey Kladov-1/+1
Stack size of 10 **bytes** does not make any sense: the minimal possible stack size is greater anyway.
2019-04-10Eliminate `FnBox` usages from libstd.CrLF0710-2/+3
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-2/+2
2019-03-27Rollup merge of #59460 - xfix:include-id-in-thread-debug, r=AmanieuJosh Stone-1/+4
Include id in Thread's Debug implementation Since Rust 1.19.0, `id` is a stable method, so there is no reason to not include it in Debug implementation.
2019-03-27Include id in Thread's Debug implementationKonrad Borowski-1/+4
Since Rust 1.19.0, id is a stable method, so there is no reason to not include it in Debug implementation.
2019-03-26Auto merge of #59136 - jethrogb:jb/sgx-std-test, r=sanxiynbors-1/+4
SGX target: fix std unit tests This fixes some tests and some code in the SGX sys implementation to make the `std` unit test suite pass. #59009 must be merged first.
2019-03-25SGX target: fix std unit testsJethro Beekman-1/+4
2019-03-20Add a test for size_of Option<ThreadId>Simon Sapin-1/+7
2019-03-19Make Option<ThreadId> no larger than ThreadId, with NonZeroU64Simon Sapin-3/+4
2019-02-28libstd => 2018Taiki Endo-29/+29
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2019-01-22Print a slightly clearer message when failing to spawn a threadJethro Beekman-1/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-10Auto merge of #56157 - RalfJung:park, r=nagisabors-5/+22
expand thread::park explanation Cc @carllerche @parched @stjepang
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-5/+5
2018-12-06Change sys::Thread::new to take the thread entry as Box<dyn FnBox() + 'static>̣Jethro Beekman-3/+19
2018-12-03improve wordingRalf Jung-3/+4
2018-11-27Fix small typo in commentMarius Nuennerich-1/+1
2018-11-23make park/unpark example more realisticRalf Jung-4/+15
2018-11-22expand thread::park explanationRalf Jung-1/+6
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-10-30thread::unpark: Avoid notifying with mutex locked.James Duley-2/+12
This means when the other thread wakes it can continue right away instead of having to wait for the mutex. Also add some comments explaining why the mutex needs to be locked in the first place.
2018-10-28Auto merge of #55043 - oliver-giersch:unchecked_thread_spawning, r=alexcrichtonbors-13/+78
Unchecked thread spawning # Summary Add an unsafe interface for spawning lifetime-unrestricted threads for library authors to build less-contrived, less-hacky safe abstractions on. # Motivation So a few years back scoped threads were entirely removed from the Rust stdlib, the reason being that it was possible to leak the scoped thread's join guards without resorting to unsafe code, which meant the concept was not completely safe, either. Only a maximally-restrictive safe API for thread spawning was kept in the stdlib, that requires `'static` lifetime bounds on both the thread closure and its return type. A number of 3rd party libraries sprung up to offer their implementations for safe scoped threads implementations. These work by essentially hiding the join guards from the user, thus forcing them to join at the end of an (internal) function scope. However, since these libraries have to use the maximally restrictive thread spawning API, they have to resort to some very contrived manipulations and subversions of Rust's type system to basically achieve what this commit does with some minimal restructuring of the current code and exposing a new unsafe function signature for spawning threads without lifetime restrictions. Obviously this is unsafe, but its main use would be to allow library authors to write safe abstractions with and around it. To further illustrate my point, here's a quick summary of the hoops that, for instance `crossbeam`, has to jump through to spawn a lifetime unrestricted thread, all of which would not be necessary if an unsafe API existed as part of the stdlib: 1. Allocate an `Arc<Option<T>>` on the heap where the result with type `T: 'a` will go (in practice requires `Mutex` or `UnsafeCell` as well). 2. Wrap the desired thread closure with lifetime bound `'a` into another closure (also `..: 'a`) that returns `()`, executes the inner closure and writes its result into the pre-allocated `Option<T>`. 3. Box the wrapping closure, cast it to a trait object (`FnBox`) and (unsafely) transmute its lifetime bound from `'a` to `'static`. So while this new `spawn_unchecked` function is certainly not very relevant for general use, since scoped threads are so common I think it makes sense to expose an interface for libraries implementing these to build on. The changes implemented are also very minimal: The current `spawn` function (which internally contains unsafe code) is moved into an unsafe `spawn_unchecked` function, which the safe function then wraps around. # Issues - ~~so far, no documentation for the new function (yet)~~ - the name of the function might be controversial, as `*_unchecked` more commonly indicates that some sort of runtime check is omitted (`unrestricted` may be more fitting) - if accepted, it might make sense to add a freestanding `thread::spawn_unchecked` function similar to the current `thread::spawn` for convenience.
2018-10-18Rollup merge of #54646 - vn971:fix_std_thread_sleep, r=frewsxcvkennytm-10/+14
improve documentation on std::thread::sleep
2018-10-16adds tracking issue numberoliver-giersch-1/+1
2018-10-15Merge pull request #5 from oliver-giersch/masteroliver-giersch-1/+1
sync with upstream
2018-10-15adds feature gate to doc-test (example)oliver-giersch-0/+1
2018-10-15adds missing method call parenthesesoliver-giersch-1/+1
2018-10-15fixes misplaced semicolonoliver-giersch-2/+2
2018-10-15adds doc for `Builder::spawn_unchecked`oliver-giersch-1/+60
2018-10-14remove unnecessary lifetime boundsoliver-giersch-2/+2
generic lifetime bound `'a` can be inferred.