Crate transportation[−][src]
This crate provides a thin callback wrapper around MIO. For each thread, a thread_local mio::Poll
is maintained. This poll can be accessed
with borrow_poll
. To listen for events on an Evented
, do the following:
use transportation::mio; let token = transportation::insert_listener(|event| println!("Got event: {:?}")); transportation::borrow_poll(|poll| poll.register(&evented, mio::Token(token), mio::Ready::readable(), mio::PollOpt::level())); transportation::run();
Re-exports
pub extern crate mio; |
Functions
borrow_poll |
Run callback with a reference to the internal MIO poll for the current thread. Transportation keeps a separate poll for every thread and it is appropriate to run transportation from multiple threads simultaneously. |
clear_interval |
Remove an existing interval. Returns true if an interval was removed or false otherwise. |
clear_timeout |
Remove an existing timeout before it has occured. Returns true if a timeout was removed or false otherwise. |
insert_listener |
Insert a listener and return a unique usize value that can be used to register one or more |
remove_listener |
Remove a previously registered listener. Returns true if a listener was removed and false otherwise. Note: The Evented item must still be removed from the poll separately. |
run |
Blocks the thread by polling on the internal MIO poll, dispatching events to event callbacks and calling set_timeout/set_interval callbacks at the appropriate times. Returns when there are no remaining registered time or event callbacks. Panics if called while transportation is already running in this same thread. |
run_in_thread |
Run a callback in a remote thread that is owned by transportation. Spins until the remote thread calls |
run_worker |
Exactly the same as |
set_interval |
Call callback after interval time has passed, then again once every interval. Returns an identifier that is unique across insert_listener, set_timeout, and set_interval that can be used with the clear_interval function. |
set_timeout |
Call callback once after timeout has passed. Returns an identifier that is unique across insert_listener, set_timeout, and set_interval that can be used with the clear_timeout function. |
stop |
Causes the event loop to exit the next time it would iterate. The event loop may be resumed with |