On Mon Jun 17 10:52:12 2024 +0000, Conor McCarthy wrote:
Oops, yeah that's true. I'll update it if !5851 doesn't go ahead.
Agreed, you always have to re-check the condition before sleeping. Honestly I don't like any more the way I wrote that loop, but it doesn't seem wrong. I think my current preferred boilerplate for a loop like that is: ```c enter_cs(); for (;;) { if (!work && !stop) wait();
if (stop) break;
do_work(); // Possibly leaving and re-entering the CS } leave_cs(); ```
Also re-entering the CS for each work item is probably not optimal in general, though probably work frequency here is sufficiently low to not matter too much. That's another matter, anyway.