pub struct Sender<T> { /* private fields */ }Expand description
A handle that allows dispatching work to a thread pool.
Implementations§
Source§impl<T: Task> Sender<T>
impl<T: Task> Sender<T>
Sourcepub fn send(&self, task: T) -> Result<(), SendError<T>>
pub fn send(&self, task: T) -> Result<(), SendError<T>>
Send a task to the thread pool, blocking if necessary
The function may result in spawning additional threads depending on the current state and configuration of the thread pool.
Sourcepub fn send_timeout(
&self,
task: T,
timeout: Duration,
) -> Result<(), SendTimeoutError<T>>
pub fn send_timeout( &self, task: T, timeout: Duration, ) -> Result<(), SendTimeoutError<T>>
Send a task to the thread pool, blocking if necessary for up to duration
Sourcepub fn try_send(&self, task: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, task: T) -> Result<(), TrySendError<T>>
Send a task to the thread pool, returning immediately if at capacity.
Source§impl Sender<Box<dyn TaskBox>>
impl Sender<Box<dyn TaskBox>>
Sourcepub fn send_fn<F>(&self, task: F) -> Result<(), SendError<Box<dyn TaskBox>>>
pub fn send_fn<F>(&self, task: F) -> Result<(), SendError<Box<dyn TaskBox>>>
Send a fn to run on the thread pool, blocking if necessary
The function may result in spawning additional threads depending on the current state and configuration of the thread pool.
Sourcepub fn send_fn_timeout<F>(
&self,
task: F,
timeout: Duration,
) -> Result<(), SendTimeoutError<Box<dyn TaskBox>>>
pub fn send_fn_timeout<F>( &self, task: F, timeout: Duration, ) -> Result<(), SendTimeoutError<Box<dyn TaskBox>>>
Send a fn to run on the thread pool, blocking if necessary for up to
duration
Sourcepub fn try_send_fn<F>(
&self,
task: F,
) -> Result<(), TrySendError<Box<dyn TaskBox>>>
pub fn try_send_fn<F>( &self, task: F, ) -> Result<(), TrySendError<Box<dyn TaskBox>>>
Send a fn to run on the thread pool, returning immediately if at capacity.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Sender<T>
impl<T> !RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>where
T: Send,
impl<T> Sync for Sender<T>where
T: Send,
impl<T> Unpin for Sender<T>
impl<T> !UnwindSafe for Sender<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more