From c6b9b675946b27094b8d97b8043e764de481f1e9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 20 Feb 2012 13:24:15 +0100 Subject: [PATCH 6/6] Removed unused condvar_wake_all related code. https://bugs.freedesktop.org/show_bug.cgi?id=44609 --- dbus/dbus-sysdeps-pthread.c | 9 --------- dbus/dbus-sysdeps-thread-win.c | 23 +---------------------- dbus/dbus-threads.c | 27 ++------------------------- dbus/dbus-threads.h | 3 +-- 4 files changed, 4 insertions(+), 58 deletions(-) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 7073751..85f89cd 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -313,14 +313,6 @@ _dbus_pthread_condvar_wake_one (DBusCondVar *cond) PTHREAD_CHECK ("pthread_cond_signal", pthread_cond_signal (&pcond->cond)); } -static void -_dbus_pthread_condvar_wake_all (DBusCondVar *cond) -{ - DBusCondVarPThread *pcond = DBUS_COND_VAR_PTHREAD (cond); - - PTHREAD_CHECK ("pthread_cond_broadcast", pthread_cond_broadcast (&pcond->cond)); -} - static const DBusThreadFunctions pthread_functions = { DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK | @@ -339,7 +331,6 @@ static const DBusThreadFunctions pthread_functions = _dbus_pthread_condvar_wait, _dbus_pthread_condvar_wait_timeout, _dbus_pthread_condvar_wake_one, - _dbus_pthread_condvar_wake_all, _dbus_pthread_mutex_new, _dbus_pthread_mutex_free, _dbus_pthread_mutex_lock, diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index e2972a3..ec462b8 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -230,26 +230,6 @@ _dbus_windows_condvar_wake_one (DBusCondVar *cond) LeaveCriticalSection (&cond->lock); } -static void -_dbus_windows_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); -} - static const DBusThreadFunctions windows_functions = { DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK | @@ -270,8 +250,7 @@ static const DBusThreadFunctions windows_functions = _dbus_windows_condvar_free, _dbus_windows_condvar_wait, _dbus_windows_condvar_wait_timeout, - _dbus_windows_condvar_wake_one, - _dbus_windows_condvar_wake_all + _dbus_windows_condvar_wake_one }; dbus_bool_t diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 37b68ba..96331c1 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -31,7 +31,7 @@ static DBusThreadFunctions thread_functions = 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -289,18 +289,6 @@ _dbus_condvar_wake_one (DBusCondVar *cond) (* thread_functions.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_functions.condvar_wake_all) - (* thread_functions.condvar_wake_all) (cond); -} - static void shutdown_global_locks (void *data) { @@ -566,7 +554,6 @@ dbus_threads_init (const DBusThreadFunctions *functions) _dbus_assert (functions->condvar_wait != NULL); _dbus_assert (functions->condvar_wait_timeout != NULL); _dbus_assert (functions->condvar_wake_one != NULL); - _dbus_assert (functions->condvar_wake_all != NULL); /* Either the mutex function set or recursive mutex set needs * to be available but not both @@ -627,7 +614,6 @@ dbus_threads_init (const DBusThreadFunctions *functions) thread_functions.condvar_wait = functions->condvar_wait; thread_functions.condvar_wait_timeout = functions->condvar_wait_timeout; thread_functions.condvar_wake_one = functions->condvar_wake_one; - thread_functions.condvar_wake_all = functions->condvar_wake_all; if (functions->mask & DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK) thread_functions.recursive_mutex_new = functions->recursive_mutex_new; @@ -700,8 +686,6 @@ static dbus_bool_t dbus_fake_condvar_wait_timeout (DBusCondVar *cond, DBusMutex *mutex, int timeout_msec); static void dbus_fake_condvar_wake_one (DBusCondVar *cond); -static void dbus_fake_condvar_wake_all (DBusCondVar *cond); - static const DBusThreadFunctions fake_functions = { @@ -723,8 +707,7 @@ static const DBusThreadFunctions fake_functions = dbus_fake_condvar_free, dbus_fake_condvar_wait, dbus_fake_condvar_wait_timeout, - dbus_fake_condvar_wake_one, - dbus_fake_condvar_wake_all + dbus_fake_condvar_wake_one }; static DBusMutex * @@ -804,12 +787,6 @@ dbus_fake_condvar_wake_one (DBusCondVar *cond) } -static void -dbus_fake_condvar_wake_all (DBusCondVar *cond) -{ - -} - dbus_bool_t _dbus_threads_init_debug (void) { diff --git a/dbus/dbus-threads.h b/dbus/dbus-threads.h index ba07ca5..4630ac5 100644 --- a/dbus/dbus-threads.h +++ b/dbus/dbus-threads.h @@ -172,8 +172,7 @@ typedef struct DBusCondVarWaitFunction condvar_wait; /**< Function to wait on a condition */ DBusCondVarWaitTimeoutFunction condvar_wait_timeout; /**< Function to wait on a condition with a timeout */ DBusCondVarWakeOneFunction condvar_wake_one; /**< Function to wake one thread waiting on the condition */ - DBusCondVarWakeAllFunction condvar_wake_all; /**< Function to wake all threads waiting on the condition */ - + DBusRecursiveMutexNewFunction recursive_mutex_new; /**< Function to create a recursive mutex */ DBusRecursiveMutexFreeFunction recursive_mutex_free; /**< Function to free a recursive mutex */ DBusRecursiveMutexLockFunction recursive_mutex_lock; /**< Function to lock a recursive mutex */ -- 1.7.4.msysgit.0