Struct actix::Arbiter

source ·
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§

source§

impl Arbiter

source

pub fn new() -> Arbiter

Spawn a new Arbiter thread and start its event loop.

§Panics

Panics if a System is not registered on the current thread.

source

pub fn with_tokio_rt<F>(runtime_factory: F) -> Arbiter
where F: Fn() -> Runtime + Send + 'static,

Spawn a new Arbiter using the Tokio Runtime returned from a closure.

source

pub fn handle(&self) -> ArbiterHandle

Return a handle to the this Arbiter’s message sender.

source

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.

source

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.

source

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.

source

pub fn spawn<Fut>(&self, future: Fut) -> bool
where Fut: Future<Output = ()> + Send + 'static,

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.

source

pub fn spawn_fn<F>(&self, f: F) -> bool
where F: FnOnce() + Send + 'static,

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.

source

pub fn join(self) -> Result<(), Box<dyn Any + Send>>

Wait for Arbiter’s event loop to complete.

Joins the underlying OS thread handle. See JoinHandle::join.

Trait Implementations§

source§

impl Debug for Arbiter

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more