[Xcb] questions about proper event loop and timers

Vincent Torri vtorri at univ-evry.fr
Sat Aug 12 09:28:21 PDT 2006


Hey,

Don't use XCBWaitForEvent. It's deprecated, iirc. Use XCBPollForEvent, 
which is, btw, non-blocking.

look at the tutorial (in xcb/doc/tutorial) or in xcb-demo to see example 
of event loops.

(something like:

while (1) {
   e = XCBPollForEvent(c, NULL);
   if (e) {
     ***
     ***
   }
}

)

otherwise, i've not advice to give you about your timer stuff.

regards

Vincent

On Sat, 12 Aug 2006, Jim Crafton wrote:

> 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
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>
> -- 
> Ce message a été vérifié par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a été trouvé.
> Message délivré par le serveur de messagerie de l'Université d'Evry.
>
>


More information about the Xcb mailing list