mirror of
https://github.com/corda/corda.git
synced 2025-01-19 03:06:36 +00:00
second attempt to fix "idle to active" fast path
If another thread succeeds in entering the "exclusive" state while we use the fast path to transition the current thread to "active", we must switch back to "idle" temporarily to allow the exclusive thread a chance to continue, and then retry the transition to "active" via the slow path.
This commit is contained in:
parent
3418a8bcbe
commit
1558b85acf
@ -2422,12 +2422,13 @@ enter(Thread* t, Thread::State s)
|
||||
// fast path
|
||||
INCREMENT(&(t->m->activeCount), 1);
|
||||
|
||||
t->state = s;
|
||||
|
||||
if (t->m->exclusive) {
|
||||
// a thread has entered exclusive mode - switch to slow path
|
||||
assert(t, t->m->activeCount > 0);
|
||||
INCREMENT(&(t->m->activeCount), -1);
|
||||
// another thread has entered the exclusive state, so we
|
||||
// return to idle and use the slow path to become active
|
||||
enter(t, Thread::IdleState);
|
||||
} else {
|
||||
t->state = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user