Fixing vtkThreadedCallbackQueue deadlock
When one is calling Wait()
on a future, the future will try to run its
priors if they are enqueued (not on hold) using a constant-time lookup
through the InvokerIndex
member. There was a race condition with the
regular path for running tasks. The queue could try to run the prior
while the user does it as well. When this happens, the computed index in
the queue is negative (because it has been popped by the regular path).
When such occurence happens, we abandon trying to run the prior.
Setting the invoker's status to RUNNING
was done in Invoke()
. It
turns out that there are cases when we want to set it before calling
Invoke()
. From now on, each part of the code about to invoke is
responsible for updating this status.