[Xcb] questions about proper event loop and timers
Jim Crafton
jim.crafton at gmail.com
Sat Aug 12 09:07:51 PDT 2006
Hi,
I'm new to xcb usage and running into a bit of problem.
I'm trying to figure out the best way to put together an event loop
that uses both timers and x events in a single thread.
If I was just catching/dispatching x events I'd do something like
XCBGenericEvent* xcbEvent = XCBWaitForEvent( connection );
while ( NULL != xcbEvent ) {
//process the event..
xcbEvent = XCBWaitForEvent( connection );
}
This works fine, no busy waiting, no CPU spiking
However if I want to add support for timers, i.e. registering some
callback function that gets invoked every x milliseconds, then I'm a
bit stuck.
As I understand it, on linux, timers are handled with timer_create() and
timer_settime(). If I use these API's then how do I set up the XCB
event loop such that I don't have to poll all the time? Won't
XCBWaitForEvent() block, and then the callback for the timer not get
triggered (because the thread is blocked in the XCBWaitForEvent()
code)?
Is there a standard way to handle timers with XCB? Alternately, would
anyone consider adding some extra functions that allow for add timer
support into the XCB API's?
Thanks
Jim Crafton
More information about the Xcb
mailing list