Struct reactor::Reactor
[−]
[src]
pub struct Reactor<'a> { /* fields omitted */ }
Methods
impl<'a> Reactor<'a>
[src]
pub fn new() -> Reactor<'a>
[src]
Construct a new Reactor with (hopefully) intelligent defaults
pub fn configured(cfg: ReactorConfig) -> Reactor<'a>
[src]
Construct a new engine with defaults specified by the user
pub fn connect<'b>(
&mut self,
hostname: &'b str,
port: usize,
handler: Box<ConnHandler<'a>>
) -> Result<Token>
[src]
&mut self,
hostname: &'b str,
port: usize,
handler: Box<ConnHandler<'a>>
) -> Result<Token>
Attempt a connection to the remote host specified at the remote hostname or ip address
and the port. This is a connection on a non-blocking socket, so the connect call will
return immediately. It requires a handler, to which it will supply a ConnResult
which
will indicate success or failure. On success, it will supply a socket, a token, and a
remote IP addr. It then expects an Option<Box<Context
>> so that it can manage its events
pub fn listen<A: ToSocketAddrs>(
&mut self,
addr: A,
handler: Box<ConnHandler<'a>>
) -> Result<Token>
[src]
&mut self,
addr: A,
handler: Box<ConnHandler<'a>>
) -> Result<Token>
Listen on the supplied IP address:port for incoming TCP connections. This returns
immediately and expects a handler to which it will supply ConnResult
and expect
Option<Box<Context
>> as a result
pub fn channel(&self) -> Sender<(Token, Tendril<Bytes, Atomic>)>
[src]
fetch the event_loop channel for notifying the event_loop of new outbound data
pub fn timeout(
&mut self,
duration: u64,
handler: Box<TimeoutHandler<'a>>
) -> TimerResult<(Timeout, Token)>
[src]
&mut self,
duration: u64,
handler: Box<TimeoutHandler<'a>>
) -> TimerResult<(Timeout, Token)>
Set a timeout to be executed by the event loop after duration milliseconds The supplied handler, which is a FnMut will be invoked no sooner than the timeout
pub fn timeout_conn(
&mut self,
duration: u64,
ctxtok: Token
) -> TimerResult<(Timeout, Token)>
[src]
&mut self,
duration: u64,
ctxtok: Token
) -> TimerResult<(Timeout, Token)>
Set a timeout to be executed by the event loop after duration milliseconds
ctxtok specifies a Context to which the timer callback will be directed
through the usual event dispatch mechanism for Context
s
This is useful for handling protocols which have a ping/pong style timeout
pub fn register<C>(&mut self, ctx: C) -> Result<Token> where
C: Context + 'static,
[src]
C: Context + 'static,
Trade in an existing context (connected to a resource) and get a Token The context will be registered for whichever events are specified in its own interest retrieved by get_interest()
pub fn deregister(&mut self, token: Token) -> Result<Box<Context>>
[src]
Trade in your token for a Context and deregister the Context's socket/evented from the event_loop
pub fn run(&mut self)
[src]
process all incoming and outgoing events in a loop
pub fn run_once(&mut self)
[src]
process all incoming and outgoing events in a loop
pub fn shutdown(&mut self)
[src]
calculates the 11th digit of pi