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>
impl<C> Reactor<C>
sourcepub fn new<P, H>(service: H, poller: P) -> Result<Self, Error>where
H: 'static + Handler<Command = C>,
P: 'static + Poll,
C: 'static + Send,
pub fn new<P, H>(service: H, poller: P) -> Result<Self, Error>where H: 'static + Handler<Command = C>, P: 'static + Poll, C: 'static + Send,
sourcepub 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,
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.
sourcepub 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,
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.
sourcepub fn controller(&self) -> Controller<C>
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.