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 runtime in spawned thread. Returns address of newly created arbiter.
Sourcepub fn with_name(name: String) -> Arbiter
pub fn with_name(name: String) -> Arbiter
Spawn new thread and run runtime in spawned thread. Returns address of newly created arbiter.
Sourcepub fn spawn_with<F, R, O>(
&self,
f: F,
) -> impl Future<Output = Result<O, RecvError>> + Send + 'static
pub fn spawn_with<F, R, O>( &self, f: F, ) -> impl Future<Output = Result<O, RecvError>> + Send + 'static
Send a function to the Arbiter’s thread and spawns it’s resulting future. This can be used to spawn non-send futures on the arbiter thread.
Sourcepub fn exec<F, R>(
&self,
f: F,
) -> impl Future<Output = Result<R, RecvError>> + Send + 'static
pub fn exec<F, R>( &self, f: F, ) -> impl Future<Output = Result<R, RecvError>> + Send + 'static
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