pub struct Arbiter { /* private fields */ }
Expand description
Arbiters provide an asynchronous execution environment for actors, functions and futures. When an Arbiter is created, it spawns a new OS thread, and hosts an event loop. Some Arbiter functions execute on the current thread.
Implementations§
source§impl Arbiter
impl Arbiter
sourcepub fn current() -> Arbiter
pub fn current() -> Arbiter
Returns the current thread’s arbiter’s address. If no Arbiter is present, then this function will panic!
sourcepub fn new() -> Arbiter
pub fn new() -> Arbiter
Spawn new thread and run event loop in spawned thread. Returns address of newly created arbiter.
sourcepub fn exec<F, R>(&self, f: F) -> impl Future<Output = Result<R, RecvError>>
pub fn exec<F, R>(&self, f: F) -> impl Future<Output = Result<R, RecvError>>
Send a function to the Arbiter’s thread. This function will be executed asynchronously. A future is created, and when resolved will contain the result of the function sent to the Arbiters thread.
sourcepub fn exec_fn<F>(&self, f: F)
pub fn exec_fn<F>(&self, f: F)
Send a function to the Arbiter’s thread, and execute it. Any result from the function is discarded.
sourcepub fn contains_item<T: 'static>() -> bool
pub fn contains_item<T: 'static>() -> bool
Check if arbiter storage contains item
sourcepub fn get_item<T: 'static, F, R>(f: F) -> R
pub fn get_item<T: 'static, F, R>(f: F) -> R
Get a reference to a type previously inserted on this arbiter’s storage.
Panics is item is not inserted
sourcepub fn get_mut_item<T: 'static, F, R>(f: F) -> R
pub fn get_mut_item<T: 'static, F, R>(f: F) -> R
Get a mutable reference to a type previously inserted on this arbiter’s storage.
Panics is item is not inserted