dbus-threads.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-threads.h  D-Bus threads handling
00003  *
00004  * Copyright (C) 2002  Red Hat Inc.
00005  *
00006  * Licensed under the Academic Free License version 2.1
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
00024 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
00025 #endif
00026 
00027 #ifndef DBUS_THREADS_H
00028 #define DBUS_THREADS_H
00029 
00030 #include <dbus/dbus-macros.h>
00031 #include <dbus/dbus-types.h>
00032 
00033 DBUS_BEGIN_DECLS
00034 
00035 typedef struct DBusMutex DBusMutex;
00036 typedef struct DBusCondVar DBusCondVar;
00037 
00038 typedef DBusMutex*  (* DBusMutexNewFunction)    (void);
00039 typedef void        (* DBusMutexFreeFunction)   (DBusMutex *mutex);
00040 typedef dbus_bool_t (* DBusMutexLockFunction)   (DBusMutex *mutex);
00041 typedef dbus_bool_t (* DBusMutexUnlockFunction) (DBusMutex *mutex);
00042 
00043 typedef DBusMutex*  (* DBusRecursiveMutexNewFunction)    (void);
00044 typedef void        (* DBusRecursiveMutexFreeFunction)   (DBusMutex *mutex);
00045 typedef void        (* DBusRecursiveMutexLockFunction)   (DBusMutex *mutex);
00046 typedef void        (* DBusRecursiveMutexUnlockFunction) (DBusMutex *mutex);
00047 
00048 typedef DBusCondVar*  (* DBusCondVarNewFunction)         (void);
00049 typedef void          (* DBusCondVarFreeFunction)        (DBusCondVar *cond);
00050 typedef void          (* DBusCondVarWaitFunction)        (DBusCondVar *cond,
00051                                                           DBusMutex   *mutex);
00052 typedef dbus_bool_t   (* DBusCondVarWaitTimeoutFunction) (DBusCondVar *cond,
00053                                                           DBusMutex   *mutex,
00054                                                           int          timeout_milliseconds);
00055 typedef void          (* DBusCondVarWakeOneFunction) (DBusCondVar *cond);
00056 typedef void          (* DBusCondVarWakeAllFunction) (DBusCondVar *cond);
00057 
00058 typedef enum 
00059 {
00060   DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK      = 1 << 0,
00061   DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK     = 1 << 1,
00062   DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK     = 1 << 2,
00063   DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK   = 1 << 3,
00064   DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK    = 1 << 4,
00065   DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK   = 1 << 5,
00066   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK   = 1 << 6,
00067   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK   = 1 << 7,
00068   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 << 8,
00069   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 << 9,
00070   DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK    = 1 << 10,
00071   DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK   = 1 << 11,
00072   DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK   = 1 << 12,
00073   DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK = 1 << 13,
00074   DBUS_THREAD_FUNCTIONS_ALL_MASK     = (1 << 13) - 1
00075 } DBusThreadFunctionsMask;
00076 
00081 typedef struct
00082 {
00083   unsigned int mask; 
00085   DBusMutexNewFunction mutex_new; 
00086   DBusMutexFreeFunction mutex_free; 
00087   DBusMutexLockFunction mutex_lock; 
00088   DBusMutexUnlockFunction mutex_unlock; 
00090   DBusCondVarNewFunction condvar_new; 
00091   DBusCondVarFreeFunction condvar_free; 
00092   DBusCondVarWaitFunction condvar_wait; 
00093   DBusCondVarWaitTimeoutFunction condvar_wait_timeout; 
00094   DBusCondVarWakeOneFunction condvar_wake_one; 
00095   DBusCondVarWakeAllFunction condvar_wake_all; 
00097   DBusRecursiveMutexNewFunction recursive_mutex_new; 
00098   DBusRecursiveMutexFreeFunction recursive_mutex_free; 
00099   DBusRecursiveMutexLockFunction recursive_mutex_lock; 
00100   DBusRecursiveMutexUnlockFunction recursive_mutex_unlock; 
00102   void (* padding1) (void); 
00103   void (* padding2) (void); 
00104   void (* padding3) (void); 
00105   void (* padding4) (void); 
00107 } DBusThreadFunctions;
00108 
00109 dbus_bool_t  dbus_threads_init         (const DBusThreadFunctions *functions);
00110 dbus_bool_t  dbus_threads_init_default (void);
00111 
00112 DBUS_END_DECLS
00113 
00114 #endif /* DBUS_THREADS_H */

Generated on Wed Jan 3 04:58:29 2007 for D-Bus by  doxygen 1.4.7