Struct reactor::Reactor

source ·
pub struct Reactor<C> { /* private fields */ }
Expand description

High-level reactor API wrapping reactor Runtime into a thread and providing basic thread management for it.

Apps running the Reactor can interface it and a Handler via use of the Controller API.

Implementations§

source§

impl<C> Reactor<C>

source

pub fn new<P, H>(service: H, poller: P) -> Result<Self, Error>where H: 'static + Handler<Command = C>, P: 'static + Poll, C: 'static + Send,

Creates new reactor using provided Poll engine and a service exposing Handler API to the reactor.

Both poll engine and the service are sent to the newly created reactor thread which runs the reactor Runtime.

Error

Errors with a system/OS error if it was impossible to spawn a thread.

source

pub fn named<P, H>( service: H, poller: P, thread_name: String ) -> Result<Self, Error>where H: 'static + Handler<Command = C>, P: 'static + Poll, C: 'static + Send,

Creates new reactor using provided Poll engine and a service exposing Handler API to the reactor.

Similar to the Reactor::new, but allows to specify the name for the reactor thread. Both poll engine and the service are sent to the newly created reactor thread which runs the reactor Runtime.

Error

Errors with a system/OS error if it was impossible to spawn a thread.

source

pub fn with<P, H>( service: H, poller: P, builder: Builder ) -> Result<Self, Error>where H: 'static + Handler<Command = C>, P: 'static + Poll, C: 'static + Send,

Creates new reactor using provided Poll engine and a service exposing Handler API to the reactor.

Similar to the Reactor::new, but allows to fully customize how the reactor thread is constructed. Both poll engine and the service are sent to the newly created reactor thread which runs the reactor Runtime.

Error

Errors with a system/OS error if it was impossible to spawn a thread.

source

pub fn controller(&self) -> Controller<C>

Provides a copy of a Controller object which exposes an API to the reactor and a service running inside of its thread.

See Handler::Command for the details.

source

pub fn join(self) -> Result<()>

Joins the reactor thread.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for Reactor<C>

§

impl<C> Send for Reactor<C>where C: Send,

§

impl<C> Sync for Reactor<C>where C: Send,

§

impl<C> Unpin for Reactor<C>

§

impl<C> !UnwindSafe for Reactor<C>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.