From 1581b764e0a14e86671bc5193516eedc621610e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20G=C3=BCnther?= Date: Thu, 3 Dec 2009 12:24:17 +0000 Subject: [PATCH] * 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 --- headers/private/kernel/condition_variable.h | 7 ++++++ src/system/kernel/condition_variable.cpp | 28 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/headers/private/kernel/condition_variable.h b/headers/private/kernel/condition_variable.h index 0f13257a12..914cb2cded 100644 --- a/headers/private/kernel/condition_variable.h +++ b/headers/private/kernel/condition_variable.h @@ -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); diff --git a/src/system/kernel/condition_variable.cpp b/src/system/kernel/condition_variable.cpp index d27a41124e..1883dcd76c 100644 --- a/src/system/kernel/condition_variable.cpp +++ b/src/system/kernel/condition_variable.cpp @@ -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() {