Remove _dbus_condvar_wake_all and both of its implementations
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 20 Feb 2012 12:56:01 +0000 (12:56 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 21 Feb 2012 14:41:44 +0000 (14:41 +0000)
Neither was used, and the Windows version could lead to live-locks.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43744
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44609
Reviewed-by: Thiago Macieira <thiago@kde.org>
dbus/dbus-sysdeps-pthread.c
dbus/dbus-sysdeps-thread-win.c
dbus/dbus-threads-internal.h
dbus/dbus-threads.c

index 9758934..c9ec9e5 100644 (file)
@@ -262,12 +262,6 @@ _dbus_platform_condvar_wake_one (DBusCondVar *cond)
   PTHREAD_CHECK ("pthread_cond_signal", pthread_cond_signal (&cond->cond));
 }
 
-void
-_dbus_platform_condvar_wake_all (DBusCondVar *cond)
-{
-  PTHREAD_CHECK ("pthread_cond_broadcast", pthread_cond_broadcast (&cond->cond));
-}
-
 static void
 check_monotonic_clock (void)
 {
index db48619..e30e7b8 100644 (file)
@@ -256,26 +256,6 @@ _dbus_platform_condvar_wake_one (DBusCondVar *cond)
   LeaveCriticalSection (&cond->lock);
 }
 
-void
-_dbus_platform_condvar_wake_all (DBusCondVar *cond)
-{
-  EnterCriticalSection (&cond->lock);
-
-  while (cond->list != NULL)
-    SetEvent (_dbus_list_pop_first (&cond->list));
-
-  if (cond->list != NULL)
-    {
-      /* Avoid live lock by pushing the waiter to the mutex lock
-         instruction, which is fair.  If we don't do this, we could
-         acquire the condition variable again before the waiter has a
-         chance itself, leading to starvation.  */
-      Sleep (0);
-    }
-
-  LeaveCriticalSection (&cond->lock);
-}
-
 dbus_bool_t
 _dbus_threads_init_platform_specific (void)
 {
index 680a603..64e8bac 100644 (file)
@@ -66,7 +66,6 @@ dbus_bool_t  _dbus_condvar_wait_timeout      (DBusCondVar       *cond,
                                               DBusCMutex        *mutex,
                                               int                timeout_milliseconds);
 void         _dbus_condvar_wake_one          (DBusCondVar       *cond);
-void         _dbus_condvar_wake_all          (DBusCondVar       *cond);
 void         _dbus_condvar_new_at_location   (DBusCondVar      **location_p);
 void         _dbus_condvar_free_at_location  (DBusCondVar      **location_p);
 
@@ -90,7 +89,6 @@ dbus_bool_t  _dbus_platform_condvar_wait_timeout (DBusCondVar   *cond,
                                               DBusCMutex        *mutex,
                                               int                timeout_milliseconds);
 void         _dbus_platform_condvar_wake_one (DBusCondVar       *cond);
-void         _dbus_platform_condvar_wake_all (DBusCondVar       *cond);
 
 DBUS_END_DECLS
 
index df00783..bb1169d 100644 (file)
@@ -343,18 +343,6 @@ _dbus_condvar_wake_one (DBusCondVar *cond)
     _dbus_platform_condvar_wake_one (cond);
 }
 
-/**
- * If there are threads waiting on the condition variable, wake
- * up all of them. 
- * Does nothing if passed a #NULL pointer.
- */
-void
-_dbus_condvar_wake_all (DBusCondVar *cond)
-{
-  if (cond && thread_init_generation == _dbus_current_generation)
-    _dbus_platform_condvar_wake_all (cond);
-}
-
 static void
 shutdown_global_locks (void *data)
 {