Fix a race-condition in TaskPool.

The lock that should surround the foreach loop was given up prematurely.
This commit is contained in:
Sönke Ludwig 2018-03-07 10:39:28 +01:00
parent eb046e2295
commit 7703cc675f

View file

@ -220,10 +220,13 @@ shared final class TaskPool {
static assert(areConvertibleTo!(Group!ARGS, Group!FARGS),
"Cannot convert arguments '"~ARGS.stringof~"' to function arguments '"~FARGS.stringof~"'.");
foreach (thr; m_state.lock.threads) {
{
auto st = m_state.lock;
foreach (thr; st.threads) {
// create one TFI per thread to properly account for elaborate assignment operators/postblit
thr.m_queue.put(callable, args);
}
}
m_signal.emit();
}
}