25#include "dbus-internals.h"
26#include "dbus-sysdeps.h"
27#include "dbus-sysdeps-win.h"
28#include "dbus-threads.h"
37static CRITICAL_SECTION init_lock;
41_dbus_threads_windows_init_global (
void)
45 _dbus_threads_windows_ensure_ctor_linked ();
47 InitializeCriticalSection (&init_lock);
48 global_init_done =
TRUE;
56static DWORD dbus_cond_event_tls = TLS_OUT_OF_INDEXES;
59static HMODULE dbus_dll_hmodule;
62_dbus_win_get_dll_hmodule (
void)
64 return dbus_dll_hmodule;
70#define hinst_t HINSTANCE
73BOOL WINAPI DllMain (hinst_t, DWORD, LPVOID);
77DllMain (hinst_t hinstDLL,
84 case DLL_PROCESS_ATTACH:
85 dbus_dll_hmodule = hinstDLL;
87 case DLL_THREAD_DETACH:
88 if (dbus_cond_event_tls != TLS_OUT_OF_INDEXES)
90 event = TlsGetValue(dbus_cond_event_tls);
92 TlsSetValue(dbus_cond_event_tls,
NULL);
95 case DLL_PROCESS_DETACH:
96 if (dbus_cond_event_tls != TLS_OUT_OF_INDEXES)
98 event = TlsGetValue(dbus_cond_event_tls);
100 TlsSetValue(dbus_cond_event_tls,
NULL);
102 TlsFree(dbus_cond_event_tls);
112_dbus_platform_cmutex_new (
void)
120_dbus_platform_rmutex_new (
void)
130 CloseHandle ((HANDLE *) mutex);
136 CloseHandle ((HANDLE *) mutex);
142 WaitForSingleObject ((HANDLE *) mutex, INFINITE);
148 WaitForSingleObject ((HANDLE *) mutex, INFINITE);
152_dbus_platform_cmutex_unlock (
DBusCMutex *mutex)
154 ReleaseMutex ((HANDLE *) mutex);
158_dbus_platform_rmutex_unlock (
DBusRMutex *mutex)
160 ReleaseMutex ((HANDLE *) mutex);
164_dbus_platform_condvar_new (
void)
174 InitializeCriticalSection (&cond->
lock);
181 DeleteCriticalSection (&cond->
lock);
193 HANDLE
event = TlsGetValue (dbus_cond_event_tls);
200 TlsSetValue (dbus_cond_event_tls, event);
203 EnterCriticalSection (&cond->
lock);
206 _dbus_assert (WaitForSingleObject (event, 0) == WAIT_TIMEOUT);
210 LeaveCriticalSection (&cond->
lock);
215 _dbus_platform_cmutex_unlock (mutex);
216 retval = WaitForSingleObject (event, milliseconds);
217 _dbus_platform_cmutex_lock (mutex);
219 if (retval == WAIT_TIMEOUT)
221 EnterCriticalSection (&cond->
lock);
228 retval = WaitForSingleObject (event, 0);
230 LeaveCriticalSection (&cond->
lock);
233#ifndef DBUS_DISABLE_ASSERT
234 EnterCriticalSection (&cond->
lock);
239 LeaveCriticalSection (&cond->
lock);
242 return retval != WAIT_TIMEOUT;
249 _dbus_condvar_wait_win32 (cond, mutex, INFINITE);
253_dbus_platform_condvar_wait_timeout (
DBusCondVar *cond,
255 int timeout_milliseconds)
257 return _dbus_condvar_wait_win32 (cond, mutex, timeout_milliseconds);
263 EnterCriticalSection (&cond->
lock);
274 LeaveCriticalSection (&cond->
lock);
283 if (dbus_cond_event_tls == TLS_OUT_OF_INDEXES)
285 dbus_cond_event_tls = TlsAlloc ();
286 if (dbus_cond_event_tls == TLS_OUT_OF_INDEXES)
297 EnterCriticalSection (&init_lock);
304 LeaveCriticalSection (&init_lock);
307#ifdef DBUS_ENABLE_VERBOSE_MODE
309_dbus_print_thread (
void)
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
dbus_bool_t _dbus_list_remove(DBusList **list, void *data)
Removes a value from the list.
void * _dbus_list_pop_first(DBusList **list)
Removes the first value in the list and returns it.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
unsigned long _dbus_pid_for_log(void)
The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...
void _dbus_threads_lock_platform_specific(void)
Lock a static mutex used to protect _dbus_threads_init_platform_specific().
void _dbus_threads_unlock_platform_specific(void)
Undo _dbus_threads_lock_platform_specific().
dbus_bool_t _dbus_threads_init_platform_specific(void)
Initialize threads as in dbus_threads_init_default(), appropriately for the platform.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
CRITICAL_SECTION lock
lock protecting the list
DBusList * list
list thread-local-stored events waiting on the cond variable