[Xcb] callback-based reply handling

Jamey Sharp jamey at minilop.net
Mon Apr 11 18:24:54 EST 2005


On Mon, Apr 11, 2005 at 01:00:33AM -0700, Barton C Massey wrote:
> In message <20050410212138.GY24279 at minilop.net> you wrote:
> > To implement the polling support, I had to add a new public function to
> > XCB: XCBGetRequestRead returns the last sequence number that the server
> > is known to have processed. This sequence number can be compared to the
> > one in a reply cookie to determine whether forcing the cookie would
> > block. (Requests with multiple replies might still block, but probably
> > not for very long...) I'm not sure that this function will remain as-is:
> > getting the test for "would-block" right is tricky in the face of 32-bit
> > sequence number wraps, and maybe we just want a function that answers
> > the "would-block" question. The function I implemented, though, should
> > be useful in Xlib, while the "would-block" function might not be.
> 
> Do both, unless some reason not to.

I had just about talked myself into doing both, yeah. OK. :-)

> We've talked about having "would-block" forever; I forget why it
> wasn't already added.

I think we couldn't see why anyone would want it, but as always I might
not be remembering correctly. If that was it, the problem is taken care
of now. :-)

> > If you use the reply thread mechanism, you'll get the best results if
> > you can ensure that reply cookies are added in order of sequence number.
> > (This is easy to ensure for a ReplyHandlers structure that has all its
> > cookies added to it by the same thread.) If cookies are added out of
> > order, some might get deferred until a later reply is processed:
> > presumably not fatal, but more delay than necessary.
> 
> Some reason not to keep the internal queue as a PQ on
> request sequence number?  Probably :-).

Nope, no reason not to. :-) Doesn't help though. At the moment I'm using
a sorted linked list for easy implementation, which (I should hope) is
equivalent.

The problem is that an item could be added to the list while the
reply-handling thread is blocked inside XCB, waiting for a later reply.
I dunno how to wake it up and make it come back to the earlier one, or
how to efficiently ensure that XCB never blocks.

--Jamey


More information about the xcb mailing list