[Xcb] [PATCH 6/8] Add event queue splitting

Keith Packard keithp at keithp.com
Thu Nov 7 04:45:40 PST 2013


Uli Schlachter <psychon at znc.in> writes:

> For bikeshedding, I would call this xcb_special_event_filter_t, because this is
> not actually an event. Having said that, feel free to ignore me.

It's more of a 'xcb_special_event_queue_t', but I decided that I just
didn't see the value in making the type name even longer...

>> +xcb_special_event_t *
>> +xcb_register_for_special_xge(xcb_connection_t *c,
>> +                             uint8_t extension,
>> +                             uint32_t eid,
>> +                             uint32_t *stamp)
>> +{
>> +    xcb_special_event_t *se;
>
>
> Add this, please:
>
>     if(c->has_error)
>         return NULL;

Right above the pthread_mutex_lock call.

> Is there any reason why this cannot return NULL on "collisisions"?
>
> Oh and: Please check for calloc() failures.

You want it to be an error to register multiple times? That seems
reasonable:

xcb_special_event_t *
xcb_register_for_special_xge(xcb_connection_t *c,
                             uint8_t extension,
                             uint32_t eid,
                             uint32_t *stamp)
{
    xcb_special_event_t *se;

    if(c->has_error)
        return NULL;
    pthread_mutex_lock(&c->iolock);
    for (se = c->in.special_events; se; se = se->next) {
        if (se->extension == extension &&
            se->eid == eid) {
            pthread_mutex_unlock(&c->iolock);
            return NULL;
        }
    }
    se = calloc(1, sizeof(xcb_special_event_t));
    if (!se) {
        pthread_mutex_unlock(&c->iolock);
        return NULL;
    }
            
    se->extension = extension;
    se->eid = eid;

    se->events = NULL;
    se->events_tail = &se->events;
    se->stamp = stamp;

    pthread_cond_init(&se->special_event_cond, 0);

    se->next = c->in.special_events;
    c->in.special_events = se;

    pthread_mutex_unlock(&c->iolock);
    return se;
}

>
>> +void
>> +xcb_unregister_for_special_event(xcb_connection_t *c,
>> +                                 xcb_special_event_t *se)
>> +{
>> +    xcb_special_event_t *s, **prev;
>> +    struct event_list   *events, *next;
>
>     if(c->has_error)
>         return;

done.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20131107/000e8fc6/attachment.pgp>


More information about the xorg-devel mailing list