#include <windows.h>
+static dbus_bool_t global_init_done = FALSE;
+static CRITICAL_SECTION init_lock;
+
+/* Called from C++ code in dbus-init-win.cpp. */
+void
+_dbus_threads_windows_init_global (void)
+{
+ /* this ensures that the object that acts as our global constructor
+ * actually gets linked in when we're linked statically */
+ _dbus_threads_windows_ensure_ctor_linked ();
+
+ InitializeCriticalSection (&init_lock);
+ global_init_done = TRUE;
+}
+
struct DBusCondVar {
DBusList *list; /**< list thread-local-stored events waiting on the cond variable */
CRITICAL_SECTION lock; /**< lock protecting the list */
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)
{
return FALSE;
}
- return dbus_threads_init (NULL);
+ return TRUE;
}
+void
+_dbus_threads_lock_platform_specific (void)
+{
+ _dbus_assert (global_init_done);
+ EnterCriticalSection (&init_lock);
+}
+
+void
+_dbus_threads_unlock_platform_specific (void)
+{
+ _dbus_assert (global_init_done);
+ LeaveCriticalSection (&init_lock);
+}