Fix a race that occurred when notifying a thread that was blocked on a
promise to wake up, but that thread simultaneously awoke for another reason (probably a timeout)
This commit is contained in:
parent
ac0f01843f
commit
c63e598497
1 changed files with 9 additions and 2 deletions
|
|
@ -79,8 +79,15 @@ namespace fc {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void promise_base::_notify(){
|
void promise_base::_notify(){
|
||||||
if( _blocked_thread != nullptr )
|
// copy _blocked_thread into a local so that if the thread unblocks (e.g.,
|
||||||
_blocked_thread->notify(ptr(this,true));
|
// because of a timeout) before we get a chance to notify it, we won't be
|
||||||
|
// calling notify on a null pointer
|
||||||
|
thread* blocked_thread;
|
||||||
|
{ synchronized(_spin_yield)
|
||||||
|
blocked_thread = _blocked_thread;
|
||||||
|
}
|
||||||
|
if( blocked_thread )
|
||||||
|
blocked_thread->notify(ptr(this,true));
|
||||||
}
|
}
|
||||||
promise_base::~promise_base() { }
|
promise_base::~promise_base() { }
|
||||||
void promise_base::_set_timeout(){
|
void promise_base::_set_timeout(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue