race between (say) wl_display_sync and wl_callback_add_listener?

John Cox jc at kynesim.co.uk
Mon Sep 25 16:10:30 UTC 2023


Hi

Assuming I have a separate poll/read_events/dispatch_queue thread to my
main thread. If I go wl_display_sync/wl_callback_add_listener on the
main thread is there a race condition between those two calls where the
other thread can read & dispatch the callback before the listener is
added or is there some magic s.t. adding the listener will always work
as expected?

I assume it must be safe if dispatch & create/add_listener are in the
same thread.

The same question applies to adding listeners after binding (say) the
shm extension where the bind provokes a set of events giving formats.

Is there a safe way of doing this? (mutex around the dispatch and
create/add_listener pairs would seem plausible even if really not what I
want to do)

Many thanks

John Cox


More information about the wayland-devel mailing list