Rapicorn - Experimental UI Toolkit - Source Code  13.07.0
Event Loops and Event Sources

Rapicorn event loops are a programming facility to execute callback handlers (dispatch event sources) according to expiring Timers, IO events or arbitrary other conditions.

A Rapicorn::EventLoop is created with Rapicorn::MainLoop::_new() or Rapicorn::MainLoop::new_slave(). Callbacks or other event sources are added to it via Rapicorn::EventLoop::add(), Rapicorn::EventLoop::exec_normal() and related functions. Once a main loop is created and its callbacks are added, it can be run as:

 while (!loop.finishable())
   loop.iterate (true);

Rapicorn::MainLoop::iterate() finds a source that immediately need dispatching and starts to dispatch it. If no source was found, it monitors the source list's PollFD descriptors for events, and finds dispatchable sources based on newly incoming events on the descriptors. If multiple sources need dispatching, they are handled according to their priorities (see Rapicorn::EventLoop::add()) and at the same priority, sources are dispatched in round-robin fashion. Calling Rapicorn::MainLoop::iterate() also iterates over its slave loops, which allows to handle sources on several independently running loops within the same thread, usually used to associate one event loop with one window.

Traits of the Rapicorn::EventLoop class:

Loop integration of a Rapicorn::EventLoop::Source class:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines