Thread affinity again

Jørgen Lind jorgen.lind at
Thu May 10 01:52:14 PDT 2012

Hi guys.

I have implemented a proposal for thread affinity for libwayland-client.

By this I mean that proxies belong to threads. So events will be
dispatched in the thread that created the proxy. Obviously proxies can
be moved between threads if that is desired.

As a side-effect I also implemented a wl_display_iterate_for_object
which takes a proxy and only dispatches events for that proxy,
effectively queuing up all other events.

Obviously requests can be sent from any thread.

The code is here:

I also implemented a test to see if there was any performance
regressions in the single threaded, which showed there wasn't.
Obviously there is a performance hit having multiple threads.

As an implementation note it can be argued that it would be cool if
the "wayland-thread" didn't need to de-marshal the events, but just
copy the data to the connection buffers of the local threads. However,
I didn't think of this when I implemented this, and this would require
additional changes to wl_connection making the change even larger.
Anyway, it can be implemented/fixed later.


More information about the wayland-devel mailing list