I know the Experimental.Threading.Future class is, as the name suggest, in experimental state. But when reading through the code I saw a race condition in InternalReject
and InternalResolve
:
protected void InternalResolve(T result)
{
if (State != FutureState.Pending)
throw new Exception();
_mutex.Lock();
State = FutureState.Resolved;
...
It should be:
_mutex.Lock();
if (State != FutureState.Pending)
{
_mutex.Unlock();
throw new Exception();
}
State = FutureState.Resolved;
...