Struct easyfibers::Runner
[−]
[src]
pub struct Runner<P, R> { /* fields omitted */ }
Runner executes fibers on main stack. There can be multiple pollers each with its own fibers of a particular type.
Methods
impl<P, R> Runner<P, R>
[src]
fn new() -> Result<Runner<P, R>>
Start runner. This function does not block. Can fail only if we ran out of space for new runners. ATM max runners is 20.
fn run(&self) -> bool
Execute fibers and timers. Returns true if anything changed and you should call pop_response and pop_fiber.
Set wait to maximum amount of time poller should wait for sockets to wake up. This affects socket timers so do not set it too large. Recommended values between 0 (if you have something else to do) and 250.
fn get_response(&self) -> Option<R>
Get a response from fiber if any available.
fn get_fiber(&self) -> Option<FiberRef<P, R>>
Get a fiber if any that has called join_main and is blocking waiting for main stack to resume it.
fn new_resolve_connect(
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
Resolve domain, connect and run fiber. In case domain resolve or connect fails, fiber will still be run but all socket operations will fail.
fn new_tcp(&self, tcp: TcpStream, func: FiberFn<P, R>, param: P) -> Result<()>
Start fiber on TCP socket.
This function does not block and fiber gets executed on next poll().
fn new_listener(
&self,
tcp: TcpListener,
func: FiberFn<P, R>,
param: P
) -> Result<()>
&self,
tcp: TcpListener,
func: FiberFn<P, R>,
param: P
) -> Result<()>
Start fiber on TCP listener.
This function does not block and fiber gets executed on next poll().
fn new_udp(&self, udp: UdpSocket, func: FiberFn<P, R>, param: P) -> Result<()>
Start fiber on UDP socket.
This function does not block and fiber gets executed on next poll().
fn new_timer(&self, dur: Duration, resp: R) -> Option<TimerRef<P, R>>
Return resp after dur. Timer is one-shot.
fn new_fiber_timer(
&self,
dur: Duration,
func: FiberFn<P, R>,
param: P
) -> Option<TimerRef<P, R>>
&self,
dur: Duration,
func: FiberFn<P, R>,
param: P
) -> Option<TimerRef<P, R>>
Run socket-less fiber after dur.