<div dir="ltr"><div>This patch replaces the current implementation of RtlQueueWorkItem with a better one using condition variables. See mail #1 for some more details.</div><div><br></div>Changes in try 2:<div><br></div><div>
* removed if-branch which accesses num_workers without locking the critical section, since this code is most likely not executed very often, and looks confusing at first sight ;-)</div><div><br></div><div>* Add an additional variable "num_items_processed", which is used to detect if other threads have processed the item in the meantime. We don't explicitly check if the specific item was processed (but just that there was some activity) and assume that the worker threads never crash (but there also wasn't any check before, so I think its save to assume this). It also doesn't matter if the variable overflows since we only compare for equality. This way we can prevent a duplicate free even in the unlikely case when the thread pauses for over 30 seconds.</div>
</div>