HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
547 stars 44 forks source link

X11: fix notifyLoop being called in parallel to main loop end #223

Closed dzaima closed 2 years ago

dzaima commented 2 years ago

Currently, the following can happen:

  1. Main thread: runs notifyBool.store(false);
  2. Auxiliary thread: runs notifyLoop, notifyBool.exchange(true) returns false; writes character to pipe & sets notifyBool to true
  3. Main thread: clears pipe

Now the pipe is clear, but notifyBool is true, meaning no notifyLoop call will do anything, and poll() will never respond.

My comment was technically correct as the events corresponding to notifyLoop calls between the poll & notifyBool clears will be processed, but I failed to consider what happens after that :/

tonsky commented 2 years ago

Thanks!