<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">[Sorry for the duplicate Alexandre, clicked the wrong button and didn't answer to the mailing list :( ^^]</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><span style="font-family:arial,sans-serif;font-size:13px">No, the worker cannot exit at the time when the variable is checked. A worker only can break out of the processing loop, when there is no new item and the condition variable timeout expires. Since the new item was added before the check (while holding the CS), the last worker cannot terminate before this element has been processed and the additional delay of 30sec to wait for new jobs.</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Nevertheless I understand that its probably a bit too much "optimized", so I'll submit a new patch later which simplifies this part a bit.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">Regards,</span><br></div><div style="font-family:arial,sans-serif;font-size:13px">
<font color="#000000"><span style="white-space:pre-wrap">Sebastian</span></font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-11 15:09 GMT+01:00 Alexandre Julliard <span dir="ltr"><<a href="mailto:julliard@winehq.org" target="_blank">julliard@winehq.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sebastian Lackner <<a href="mailto:sebastian@fds-team.de">sebastian@fds-team.de</a>> writes:<br>
<br>
> * Its also on purpose, that num_workers is (read-) accessed at one point<br>
> without locking the critical section. If num_workers > 0 we can be sure, that<br>
> a worker thread will process the work item (sooner or later). If<br>
> num_workers == 0 we enter the critical section, and check once more to<br>
> prevent race condition 2.<br>
<br>
The worker may be about to exit at the time you check. I don't think it<br>
makes any sense to add races to "optimize" an error case that's not<br>
going to happen anyway.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alexandre Julliard<br>
<a href="mailto:julliard@winehq.org">julliard@winehq.org</a><br>
</font></span></blockquote></div><br></div>