Crates.io | scoped_threads |
lib.rs | scoped_threads |
version | 0.1.0 |
source | src |
created_at | 2020-03-29 12:31:41.664061 |
updated_at | 2020-03-29 12:31:41.664061 |
description | Lightweight, safe and idiomatic scoped threads |
homepage | |
repository | https://github.com/a1phyr/scoped_threads |
max_upload_size | |
id | 224053 |
size | 17,341 |
Lightweight, safe and idiomatic scoped threads
This crate provides a scoped alternative to std::thread
, ie threads that can
use non-static data, such as references to the stack of the parent thread. It
mimics std
's thread interface, so there is nothing to learn to use this crate.
There is a meaningful difference, though: a dropped JoinHandle
joins the
spawned thread instead of detaching it, to ensure that borrowed data is still
valid. Additionnally, this crate does not redefine types and functions that are
not related to threads being scoped, such as thread::park
.
It is lightweight in the sense that it does not uses expensive thread
synchronisation such as Arc
, locks or channels.
This crate's API is very unlikely to change and can be considered stable, but
the crate will only reach 1.0 when unstable feature thread_spawn_unchecked
is
stabilized.
scoped_threads
and not crossbeam_utils::scope
?You might not want to bring extra ShardedLocks, CachePadded, etc with your scoped threads
The scope
function works great but it feels a bit weird and is not flexible
Synchronisation primitives such as Arc
and Mutex
are extensively used and
bring a significant overhead
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.