1 //! Support for concurrent and parallel programming.
3 //! This crate is an early work in progress. The focus for the moment is
6 //! - **Non-blocking data structures**. These data structures allow for high
7 //! performance, highly-concurrent access, much superior to wrapping with a
8 //! `Mutex`. Ultimately the goal is to include stacks, queues, deques, bags,
9 //! sets and maps. These live in the `sync` module.
11 //! - **Memory management**. Because non-blocking data structures avoid global
12 //! synchronization, it is not easy to tell when internal data can be safely
13 //! freed. The `mem` module provides generic, easy to use, and high-performance
14 //! APIs for managing memory in these cases. These live in the `mem` module.
16 //! - **Synchronization**. The standard library provides a few synchronization
17 //! primitives (locks, semaphores, barriers, etc) but this crate seeks to expand
18 //! that set to include more advanced/niche primitives, as well as userspace
19 //! alternatives. These live in the `sync` module.
21 //! - **Scoped thread API**. Finally, the crate provides a "scoped" thread API,
22 //! making it possible to spawn threads that share stack data with their
23 //! parents. This functionality is exported at the top-level.
25 //#![deny(missing_docs)]
27 #![cfg_attr(feature = "nightly",
28 feature(const_fn
, repr_simd
, optin_builtin_traits
))]
32 pub use scoped
::{scope, Scope, ScopedJoinHandle}
;
40 fn call_box(self: Box
<Self>);
43 impl<F
: FnOnce()> FnBox
for F
{
44 fn call_box(self: Box
<Self>) { (*self)() }
47 /// Like `std::thread::spawn`, but without the closure bounds.
48 pub unsafe fn spawn_unsafe
<'a
, F
>(f
: F
) -> thread
::JoinHandle
<()> where F
: FnOnce() + Send
+ 'a
{
51 let closure
: Box
<FnBox
+ 'a
> = Box
::new(f
);
52 let closure
: Box
<FnBox
+ Send
> = mem
::transmute(closure
);
53 thread
::spawn(move || closure
.call_box())