On Fri Mar 8 18:22:30 2024 +0000, Rémi Bernon wrote:
Not sure to see why you need the lock here then if it's indeed safe to read it without a lock.
It's only safe to read the `ctx->draw->swap_interval` without a lock from the thread that the context is current in (because that's the only thread that can write to `ctx->draw` and `ctx->draw->swap_interval`).
This lock is to protect the read of `old->swap_interval` in `wayland_update_gl_drawable` which can happen from another thread. That is, one thread updates the drawable for a window, while another does SwapInterval on that soon-to-be-old drawable.
This lock was more important in the version with the refresh flag. I guess you could argue that since this is an inherently racy situation anyway (in terms of whether the update or swap interval happens first), we could now skip the lock and just make sure `ctx->swap_interval` is accessed atomically, although I don't think this is much of win in terms of clarity.