[haiku-commits] r34458 - in haiku/trunk: headers/private/kernel src/system/kernel

  • From: coling@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 3 Dec 2009 13:24:17 +0100 (CET)

Author: colin
Date: 2009-12-03 13:24:17 +0100 (Thu, 03 Dec 2009)
New Revision: 34458
Changeset: http://dev.haiku-os.org/changeset/34458/haiku

Modified:
   haiku/trunk/headers/private/kernel/condition_variable.h
   haiku/trunk/src/system/kernel/condition_variable.cpp
Log:
* 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 
//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).


Modified: haiku/trunk/headers/private/kernel/condition_variable.h
===================================================================
--- haiku/trunk/headers/private/kernel/condition_variable.h     2009-12-03 
12:11:14 UTC (rev 34457)
+++ haiku/trunk/headers/private/kernel/condition_variable.h     2009-12-03 
12:24:17 UTC (rev 34458)
@@ -63,6 +63,13 @@
        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);

Modified: haiku/trunk/src/system/kernel/condition_variable.cpp
===================================================================
--- haiku/trunk/src/system/kernel/condition_variable.cpp        2009-12-03 
12:11:14 UTC (rev 34457)
+++ haiku/trunk/src/system/kernel/condition_variable.cpp        2009-12-03 
12:24:17 UTC (rev 34458)
@@ -261,6 +261,34 @@
 }
 
 
+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()
 {


Other related posts: