[Xcb] Best way to manage server responses in a non-blocking way?

Bart Massey bart at cs.pdx.edu
Thu Oct 29 10:38:53 PDT 2015


Use threads! This will work ever so much easier and more reliably if you
let the xcb code run in a separate thread that can block

On Thu, Oct 29, 2015, 10:36 Uli Schlachter <psychon at znc.in> wrote:

> Hi,
>
> [...]
> > So my questions here are:
> >
> > 1) Is this the correct way to read events and replies from the server?
> > I understand that if I call xcb_poll_for_event when the next response
> > is a reply, it will return a NULL. But I'm not sure if I will be able
> > to read the reply using xcb_poll_for_reply after that...
>
> XCB never throws away replies/events (unless you tell it to via
> xcb_discard_reply()). So yeah, you can just poll for reply after a poll for
> event wasn't successful.
>
> Actually, I guess first polling for replies makes more sense...
>
> > 2) I can not find any example of xcb_poll_for_reply on internet. Is
> > there any documentation about it? I'm not sure about how to implement
> > layer_nextReply, since in XCB there is no "generic" replies. (maybe
> > iterating a list of stored cookies doing the propper castings?)
> [...]
>
> I was surprised that there is no docs for it... Anyway, this is just
> xcb_wait_for_reply() without the waiting part. If no reply and no error was
> received yet, it will just return NULL.
>
> Note that you have to make sure that your requests are actually send out
> before
> there can be any reply for them (xcb_flush()). xcb_wait_for_reply()
> automatically flushes for you, so this might be easy to miss.
>
> Cheers,
> Uli
> --
> If you have to type the letters "A-E-S" into your source code, you're
> doing it
> wrong.
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20151029/88033660/attachment.html>


More information about the Xcb mailing list