Mercurial > projects > dbus-d
annotate dbus-d/dsrc/org/freedesktop/dbus/c/Threads.d @ 0:a5576806d36d
recreate repository without any libs for lightweight repository
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 20 Oct 2007 18:07:18 +0200 |
parents | |
children |
rev | line source |
---|---|
0
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /* -*- mode: C; c-file-style: "gnu" -*- */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 /* dbus-threads.h D-Bus threads handling |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * Copyright (C) 2002 Red Hat Inc. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * Licensed under the Academic Free License version 2.1 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
11 * (at your option) any later version. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 module org.freedesktop.dbus.c.Threads; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 import org.freedesktop.dbus.c.Types; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 extern(C): |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 /** |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 * @addtogroup DBusThreads |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 * @{ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 /** An opaque mutex type provided by the #DBusThreadFunctions implementation installed by dbus_threads_init(). */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 struct DBusMutex {}; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 /** An opaque condition variable type provided by the #DBusThreadFunctions implementation installed by dbus_threads_init(). */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 struct DBusCondVar {}; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 /** Deprecated, provide DBusRecursiveMutexNewFunction instead. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 alias DBusMutex* (* DBusMutexNewFunction) (); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 /** Deprecated, provide DBusRecursiveMutexFreeFunction instead. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 alias void (* DBusMutexFreeFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 /** Deprecated, provide DBusRecursiveMutexLockFunction instead. Return value is lock success, but gets ignored in practice. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 alias dbus_bool_t (* DBusMutexLockFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 /** Deprecated, provide DBusRecursiveMutexUnlockFunction instead. Return value is unlock success, but gets ignored in practice. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 alias dbus_bool_t (* DBusMutexUnlockFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 /** Creates a new recursively-lockable mutex, or returns #NULL if not |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 * enough memory. Can only fail due to lack of memory. Found in |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 * #DBusThreadFunctions. Do not just use PTHREAD_MUTEX_RECURSIVE for |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 * this, because it does not save/restore the recursion count when |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 * waiting on a condition. libdbus requires the Java-style behavior |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 * where the mutex is fully unlocked to wait on a condition. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 alias DBusMutex* (* DBusRecursiveMutexNewFunction) (); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 /** Frees a recursively-lockable mutex. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 alias void (* DBusRecursiveMutexFreeFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 /** Locks a recursively-lockable mutex. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 * Can only fail due to lack of memory. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 alias void (* DBusRecursiveMutexLockFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 /** Unlocks a recursively-lockable mutex. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 * Can only fail due to lack of memory. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 alias void (* DBusRecursiveMutexUnlockFunction) (DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 /** Creates a new condition variable. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 * Can only fail (returning #NULL) due to lack of memory. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 alias DBusCondVar* (* DBusCondVarNewFunction) (); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 /** Frees a condition variable. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 alias void (* DBusCondVarFreeFunction) (DBusCondVar *cond); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 /** Waits on a condition variable. Found in |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 * #DBusThreadFunctions. Must work with either a recursive or |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 * nonrecursive mutex, whichever the thread implementation |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 * provides. Note that PTHREAD_MUTEX_RECURSIVE does not work with |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 * condition variables (does not save/restore the recursion count) so |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 * don't try using simply pthread_cond_wait() and a |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 * PTHREAD_MUTEX_RECURSIVE to implement this, it won't work right. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 * Has no error conditions. Must succeed if it returns. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 alias void (* DBusCondVarWaitFunction) (DBusCondVar *cond, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 DBusMutex *mutex); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 /** Waits on a condition variable with a timeout. Found in |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 * #DBusThreadFunctions. Returns #TRUE if the wait did not |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 * time out, and #FALSE if it did. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 * Has no error conditions. Must succeed if it returns. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 alias dbus_bool_t (* DBusCondVarWaitTimeoutFunction) (DBusCondVar *cond, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 DBusMutex *mutex, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 int timeout_milliseconds); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 /** Wakes one waiting thread on a condition variable. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 * Has no error conditions. Must succeed if it returns. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 alias void (* DBusCondVarWakeOneFunction) (DBusCondVar *cond); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 /** Wakes all waiting threads on a condition variable. Found in #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 * Has no error conditions. Must succeed if it returns. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 alias void (* DBusCondVarWakeAllFunction) (DBusCondVar *cond); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 /** |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 * Flags indicating which functions are present in #DBusThreadFunctions. Used to allow |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 * the library to detect older callers of dbus_threads_init() if new possible functions |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 * are added to #DBusThreadFunctions. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 enum DBusThreadFunctionsMask{ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK = 1 << 0, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK = 1 << 1, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK = 1 << 2, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK = 1 << 3, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK = 1 << 4, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK = 1 << 5, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK = 1 << 6, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK = 1 << 7, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 << 8, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 << 9, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK = 1 << 10, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK = 1 << 11, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK = 1 << 12, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK = 1 << 13, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 DBUS_THREAD_FUNCTIONS_ALL_MASK = (1 << 14) - 1 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 } ; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 /** |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 * Functions that must be implemented to make the D-Bus library |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 * thread-aware. The recursive mutex functions should be specified |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 * rather than the old, deprecated nonrecursive ones. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 * The condition variable functions have to work with recursive |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 * mutexes if you provide those, or with nonrecursive mutexes if you |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 * provide those. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 * If implementing threads using pthreads, be aware that |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 * PTHREAD_MUTEX_RECURSIVE is broken in combination with condition |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 * variables. libdbus relies on the Java-style behavior that when |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 * waiting on a condition, the recursion count is saved and restored, |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 * and the mutex is completely unlocked, not just decremented one |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 * level of recursion. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 * |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 * Thus with pthreads you probably have to roll your own emulated |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 * recursive mutexes, you can't use PTHREAD_MUTEX_RECURSIVE. This is |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 * what dbus_threads_init_default() does on platforms that use |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 * pthreads. |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 struct DBusThreadFunctions{ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 uint mask; /**< Mask indicating which functions are present. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 DBusMutexNewFunction mutex_new; /**< Function to create a mutex; optional and deprecated. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 DBusMutexFreeFunction mutex_free; /**< Function to free a mutex; optional and deprecated. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 DBusMutexLockFunction mutex_lock; /**< Function to lock a mutex; optional and deprecated. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 DBusMutexUnlockFunction mutex_unlock; /**< Function to unlock a mutex; optional and deprecated. */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 DBusCondVarNewFunction condvar_new; /**< Function to create a condition variable */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 DBusCondVarFreeFunction condvar_free; /**< Function to free a condition variable */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 DBusCondVarWaitFunction condvar_wait; /**< Function to wait on a condition */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 DBusCondVarWaitTimeoutFunction condvar_wait_timeout; /**< Function to wait on a condition with a timeout */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 DBusCondVarWakeOneFunction condvar_wake_one; /**< Function to wake one thread waiting on the condition */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 DBusCondVarWakeAllFunction condvar_wake_all; /**< Function to wake all threads waiting on the condition */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 DBusRecursiveMutexNewFunction recursive_mutex_new; /**< Function to create a recursive mutex */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 DBusRecursiveMutexFreeFunction recursive_mutex_free; /**< Function to free a recursive mutex */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 DBusRecursiveMutexLockFunction recursive_mutex_lock; /**< Function to lock a recursive mutex */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 DBusRecursiveMutexUnlockFunction recursive_mutex_unlock; /**< Function to unlock a recursive mutex */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 void (* padding1) (); /**< Reserved for future expansion */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 void (* padding2) (); /**< Reserved for future expansion */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 void (* padding3) (); /**< Reserved for future expansion */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 void (* padding4) (); /**< Reserved for future expansion */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
177 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
178 } ; |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
179 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 dbus_bool_t dbus_threads_init (DBusThreadFunctions *functions); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 dbus_bool_t dbus_threads_init_default (); |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
182 |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
183 /** @} */ |
a5576806d36d
recreate repository without any libs for lightweight repository
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
184 |