17 Jun
2024
17 Jun
'24
11:12 a.m.
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:
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. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5830#note_73416