* processed. This function enables applications to determine whether
* forcing a cookie is going to block.
*
- * @todo review that function.
+ * @deprecated This function is deprecated in favor of XCBPollForReply.
+ * It must not be used in newly written code.
*/
-unsigned int XCBGetRequestRead(XCBConnection *c);
+unsigned int XCBGetRequestRead(XCBConnection *c) deprecated;
/* xcb_ext.c */
return len;
}
+static int poll_for_reply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error)
+{
+ struct reply_list *head;
+
+ if(!request)
+ head = 0;
+ else if(c->in.request_completed >= request)
+ {
+ head = _xcb_map_remove(c->in.replies, request);
+ if(head && head->next)
+ _xcb_map_put(c->in.replies, request, head->next);
+ }
+ else if(c->in.request_read == request && c->in.current_reply)
+ {
+ head = c->in.current_reply;
+ c->in.current_reply = head->next;
+ if(!head->next)
+ c->in.current_reply_tail = &c->in.current_reply;
+ }
+ else
+ /* Would block: do nothing. */
+ return 0;
+
+ if(error)
+ *error = 0;
+ *reply = 0;
+
+ if(head)
+ {
+ if(((XCBGenericRep *) head->reply)->response_type == XCBError)
+ {
+ if(error)
+ *error = head->reply;
+ else
+ free(head->reply);
+ }
+ else
+ *reply = head->reply;
+
+ free(head);
+ }
+
+ return 1;
+}
+
/* Public interface */
void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e)
return ret;
}
+int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error)
+{
+ int ret;
+ assert(reply != 0);
+ pthread_mutex_lock(&c->iolock);
+ ret = poll_for_reply(c, request, reply, error);
+ pthread_mutex_unlock(&c->iolock);
+ return ret;
+}
+
XCBGenericEvent *XCBWaitEvent(XCBConnection *c)
{
return XCBWaitForEvent(c);
/* xcb_in.c */
void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e);
+int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error);
/* xcb_xid.c */
#include "xcb.h"
/* This function must be called with the IOLock held. */
-unsigned int XCBGetQueuedRequestRead(XCBConnection *c);
+unsigned int XCBGetQueuedRequestRead(XCBConnection *c) deprecated;
/* This function must be called with the IOLock held. */
unsigned int XCBGetRequestSent(XCBConnection *c);