Struct entangled::ThreadPool [−][src]
A thread pool for executing futures.
Drives given futures to completion.
Implementations
impl ThreadPool
[src]
pub fn new(descriptor: ThreadPoolDescriptor) -> Result<Self, Error>
[src]
Create a new ThreadPool
. Thread pools can be freely cloned.
How to provide a custom handler
use entangled::*; let descriptor = ThreadPoolDescriptor { num_threads: 0, start_handler: Some(Box::new(|index| { println!("Thread {} is starting", index); })), ..Default::default() }; let pool = ThreadPool::new(descriptor).unwrap();
pub fn scope<'scope, S, R>(&self, s: S) -> Vec<R> where
S: FnOnce(&mut Scope<'scope, R>) + 'scope + Send,
R: Send + 'static,
[src]
S: FnOnce(&mut Scope<'scope, R>) + 'scope + Send,
R: Send + 'static,
Creates a “fork-join” scope s
and invokes the closure with a reference to s
.
This closure can then spawn futures into s
. When the closure returns, it will block
until all futures that have been spawned into s
complete.
In general, spawned futures may access stack data in place that outlives the scope itself. Other data must be fully owned by the spawned future.
pub fn spawn<T>(
&self,
future: impl Future<Output = T> + Send + 'static
) -> Task<T> where
T: Send + 'static,
[src]
&self,
future: impl Future<Output = T> + Send + 'static
) -> Task<T> where
T: Send + 'static,
Spawns a static future onto the thread pool. The returned Task
is a future. It can also be
cancelled and “detached” allowing it to continue running without having to be polled by the
end-user.
Trait Implementations
impl Clone for ThreadPool
[src]
fn clone(&self) -> ThreadPool
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ThreadPool
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,