1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-threads.h D-BUS threads handling
4 * Copyright (C) 2002 Red Hat Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
24 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
27 #ifndef DBUS_THREADS_H
28 #define DBUS_THREADS_H
30 #include <dbus/dbus-macros.h>
31 #include <dbus/dbus-types.h>
35 typedef struct DBusMutex DBusMutex;
36 typedef struct DBusCondVar DBusCondVar;
38 typedef DBusMutex* (* DBusMutexNewFunction) (void);
39 typedef void (* DBusMutexFreeFunction) (DBusMutex *mutex);
40 typedef dbus_bool_t (* DBusMutexLockFunction) (DBusMutex *mutex);
41 typedef dbus_bool_t (* DBusMutexUnlockFunction) (DBusMutex *mutex);
43 typedef DBusCondVar* (* DBusCondVarNewFunction) (void);
44 typedef void (* DBusCondVarFreeFunction) (DBusCondVar *cond);
45 typedef void (* DBusCondVarWaitFunction) (DBusCondVar *cond,
47 typedef dbus_bool_t (* DBusCondVarWaitTimeoutFunction) (DBusCondVar *cond,
49 int timeout_milliseconds);
50 typedef void (* DBusCondVarWakeOneFunction) (DBusCondVar *cond);
51 typedef void (* DBusCondVarWakeAllFunction) (DBusCondVar *cond);
55 DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK = 1 << 0,
56 DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK = 1 << 1,
57 DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK = 1 << 2,
58 DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK = 1 << 3,
59 DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK = 1 << 4,
60 DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK = 1 << 5,
61 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK = 1 << 6,
62 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK = 1 << 7,
63 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 << 8,
64 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 << 9,
66 DBUS_THREAD_FUNCTIONS_ALL_MASK = (1 << 10) - 1
67 } DBusThreadFunctionsMask;
73 DBusMutexNewFunction mutex_new;
74 DBusMutexFreeFunction mutex_free;
75 DBusMutexLockFunction mutex_lock;
76 DBusMutexUnlockFunction mutex_unlock;
78 DBusCondVarNewFunction condvar_new;
79 DBusCondVarFreeFunction condvar_free;
80 DBusCondVarWaitFunction condvar_wait;
81 DBusCondVarWaitTimeoutFunction condvar_wait_timeout;
82 DBusCondVarWakeOneFunction condvar_wake_one;
83 DBusCondVarWakeAllFunction condvar_wake_all;
85 void (* padding1) (void);
86 void (* padding2) (void);
87 void (* padding3) (void);
88 void (* padding4) (void);
89 void (* padding5) (void);
90 void (* padding6) (void);
91 void (* padding7) (void);
92 void (* padding8) (void);
94 } DBusThreadFunctions;
97 DBusMutex* dbus_mutex_new (void);
98 void dbus_mutex_free (DBusMutex *mutex);
99 dbus_bool_t dbus_mutex_lock (DBusMutex *mutex);
100 dbus_bool_t dbus_mutex_unlock (DBusMutex *mutex);
102 DBusCondVar* dbus_condvar_new (void);
103 void dbus_condvar_free (DBusCondVar *cond);
104 void dbus_condvar_wait (DBusCondVar *cond,
106 dbus_bool_t dbus_condvar_wait_timeout (DBusCondVar *cond,
108 int timeout_milliseconds);
109 void dbus_condvar_wake_one (DBusCondVar *cond);
110 void dbus_condvar_wake_all (DBusCondVar *cond);
112 dbus_bool_t dbus_threads_init (const DBusThreadFunctions *functions);
118 #endif /* DBUS_THREADS_H */