Make use of the wait status field so it can be provided in Notify() and then

read out in the ConditionVariableEntry::WaitStatus(). That way you can notify
with a specific status that can be read out on the other end.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33718 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-10-21 23:44:59 +00:00
parent ec39794897
commit 5ee1f125e5
2 changed files with 25 additions and 14 deletions
+11 -5
View File
@@ -241,7 +241,7 @@ ConditionVariable::Unpublish(bool threadsLocked)
fObjectType = NULL;
if (!fEntries.IsEmpty())
_NotifyChecked(true, B_ENTRY_NOT_FOUND);
_NotifyLocked(true, B_ENTRY_NOT_FOUND);
}
@@ -293,14 +293,20 @@ ConditionVariable::Dump() const
void
ConditionVariable::_Notify(bool all, bool threadsLocked)
ConditionVariable::_Notify(bool all, bool threadsLocked, status_t result)
{
InterruptsLocker _;
SpinLocker threadLocker(threadsLocked ? NULL : &gThreadSpinlock);
SpinLocker locker(sConditionVariablesLock);
if (!fEntries.IsEmpty())
_NotifyChecked(all, B_OK);
if (!fEntries.IsEmpty()) {
if (result > B_OK) {
panic("tried to notify with invalid result %ld\n", result);
result = B_ERROR;
}
_NotifyLocked(all, result);
}
}
@@ -308,7 +314,7 @@ ConditionVariable::_Notify(bool all, bool threadsLocked)
thread lock held.
*/
void
ConditionVariable::_NotifyChecked(bool all, status_t result)
ConditionVariable::_NotifyLocked(bool all, status_t result)
{
// dequeue and wake up the blocked threads
while (ConditionVariableEntry* entry = fEntries.RemoveHead()) {