Struct reactor::ReactorCtrl
[−]
[src]
pub struct ReactorCtrl<'a, 'b: 'a> { /* fields omitted */ }
ReactorCtrl is the event-loop control interface which is passed to every handler, both the listen/connect handlers as well as the mailbox for every Context that is managed by Reactor
Methods
impl<'a, 'b: 'a> ReactorCtrl<'a, 'b>
[src]
pub fn connect<'c>(
&mut self,
hostname: &'c str,
port: usize,
handler: Box<ConnHandler<'b>>
) -> Result<Token>
[src]
&mut self,
hostname: &'c str,
port: usize,
handler: Box<ConnHandler<'b>>
) -> 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<'b>>
) -> Result<Token>
[src]
&mut self,
addr: A,
handler: Box<ConnHandler<'b>>
) -> 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<'b>>
) -> TimerResult<(Timeout, Token)>
[src]
&mut self,
duration: u64,
handler: Box<TimeoutHandler<'b>>
) -> TimerResult<(Timeout, Token)>
Set a timeout to be executed by the event loop after duration Minimum expected resolution is the tick duration of the event loop poller, but it could be shorted depending on how many events are occurring
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 handler of a Context for a given token. This is useful for protocols which have timeouts or timed ping/pongs such as IRC.
pub fn register<C>(&mut self, ctx: C) -> Result<Token> where
C: Context + 'static,
[src]
C: Context + 'static,
Supply a context to the event_loop for monitoring and get back a token
pub fn deregister(&mut self, token: Token) -> Result<Box<Context>>
[src]
deregister a context for a given token and receive back the context NOTE : You cannot deregister the context for a token while running in the handler of that context. It must be called for a different context
pub fn shutdown(&mut self)
[src]
calculates the 11th digit of pi