[][src]Struct calloop::EventLoop

pub struct EventLoop<Data> { /* fields omitted */ }

An event loop

This loop can host several event sources, that can be dynamically added or removed.

Implementations

impl<Data> EventLoop<Data>[src]

pub fn new() -> Result<EventLoop<Data>>[src]

Create a new event loop

Fails if the initialization of the polling system failed.

pub fn handle(&self) -> LoopHandle<Data>[src]

Retrieve a loop handle

pub fn dispatch<D: Into<Option<Duration>>>(
    &mut self,
    timeout: D,
    data: &mut Data
) -> Result<()>
[src]

Dispatch pending events to their callbacks

Some source have events available, their callbacks will be immediatly called. Otherwise this will wait until an event is receive or the provided timeout is reached. If timeout is None, it will wait without a duration limit.

Once pending events have been processed or the timeout is reached, all pending idle callbacks will be fired before this method returns.

pub fn get_signal(&self) -> LoopSignal[src]

Get a signal to stop this event loop from running

To be used in conjunction with the run() method.

pub fn run<F>(
    &mut self,
    timeout: Option<Duration>,
    data: &mut Data,
    cb: F
) -> Result<()> where
    F: FnMut(&mut Data), 
[src]

Run this event loop

This will repeatedly try to dispatch events (see the dispatch() method) on this event loop, waiting at most timeout every time.

Between each dispatch wait, your provided callback will be called.

You can use the get_signal() method to retrieve a way to stop or wakeup the event loop from anywhere.

Auto Trait Implementations

impl<Data> !RefUnwindSafe for EventLoop<Data>

impl<Data> !Send for EventLoop<Data>

impl<Data> !Sync for EventLoop<Data>

impl<Data> Unpin for EventLoop<Data>

impl<Data> !UnwindSafe for EventLoop<Data>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.