pub struct Arbiter { /* private fields */ }
Expand description
An Arbiter represents a thread that provides an asynchronous execution environment for futures and functions.
When an arbiter is created, it spawns a new OS thread, and hosts an event loop.
Implementations
sourceimpl Arbiter
impl Arbiter
sourcepub fn with_tokio_rt<F>(runtime_factory: F) -> Arbiter where
F: 'static + Fn() -> Runtime + Send,
pub fn with_tokio_rt<F>(runtime_factory: F) -> Arbiter where
F: 'static + Fn() -> Runtime + Send,
Spawn a new Arbiter using the Tokio Runtime returned from a closure.
sourcepub fn handle(&self) -> ArbiterHandle
pub fn handle(&self) -> ArbiterHandle
Return a handle to the this Arbiter’s message sender.
sourcepub fn current() -> ArbiterHandle
pub fn current() -> ArbiterHandle
Return a handle to the current thread’s Arbiter’s message sender.
Panics
Panics if no Arbiter is running on the current thread.
sourcepub fn try_current() -> Option<ArbiterHandle>
pub fn try_current() -> Option<ArbiterHandle>
Try to get current running arbiter handle.
Returns None
if no Arbiter has been started.
Unlike current
, this never panics.
sourcepub fn stop(&self) -> bool
pub fn stop(&self) -> bool
Stop Arbiter from continuing it’s event loop.
Returns true if stop message was sent successfully and false if the Arbiter has been dropped.
sourcepub fn spawn<Fut>(&self, future: Fut) -> bool where
Fut: 'static + Future<Output = ()> + Send,
pub fn spawn<Fut>(&self, future: Fut) -> bool where
Fut: 'static + Future<Output = ()> + Send,
Send a future to the Arbiter’s thread and spawn it.
If you require a result, include a response channel in the future.
Returns true if future was sent successfully and false if the Arbiter has died.
sourcepub fn spawn_fn<F>(&self, f: F) -> bool where
F: 'static + FnOnce() + Send,
pub fn spawn_fn<F>(&self, f: F) -> bool where
F: 'static + FnOnce() + Send,
Send a function to the Arbiter’s thread and execute it.
Any result from the function is discarded. If you require a result, include a response channel in the function.
Returns true if function was sent successfully and false if the Arbiter has died.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Arbiter
impl Send for Arbiter
impl Sync for Arbiter
impl Unpin for Arbiter
impl !UnwindSafe for Arbiter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more