* Adding static Notify{One,All} functions. This allows a cleaner implementation

of the condition variable and synchronization subsystem of the freebsd compat
  layer which will be committed next.
* Also there was a discussion about adding these functions on the commit
  mailing list. The mail in http://www.freelists.org/post/haiku-commits/r34395-in-haikutrunksrclibscompatfreebsd-network-compatsys,3
  is a good sum up of it (need to scroll somewhat down, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34458 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Colin Günther 2009-12-03 12:24:17 +00:00
parent b69c120bfd
commit 1581b764e0
2 changed files with 35 additions and 0 deletions

View File

@ -63,6 +63,13 @@ public:
inline void NotifyAll(bool threadsLocked = false,
status_t result = B_OK);
static void NotifyOne(const void* object,
bool threadsLocked = false,
status_t result = B_OK);
static void NotifyAll(const void* object,
bool threadsLocked = false,
status_t result = B_OK);
void Add(ConditionVariableEntry* entry);
status_t Wait(uint32 flags = 0, bigtime_t timeout = 0);

View File

@ -261,6 +261,34 @@ ConditionVariable::Wait(uint32 flags, bigtime_t timeout)
}
void
ConditionVariable::NotifyOne(const void* object, bool threadsLocked,
status_t result)
{
InterruptsSpinLocker locker(sConditionVariablesLock);
ConditionVariable* variable = sConditionVariableHash.Lookup(object);
locker.Unlock();
if (variable == NULL)
return;
variable->NotifyOne(threadsLocked, result);
}
void
ConditionVariable::NotifyAll(const void* object,
bool threadsLocked, status_t result)
{
InterruptsSpinLocker locker(sConditionVariablesLock);
ConditionVariable* variable = sConditionVariableHash.Lookup(object);
locker.Unlock();
if (variable == NULL)
return;
variable->NotifyAll(threadsLocked, result);
}
/*static*/ void
ConditionVariable::ListAll()
{