Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

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 1.2
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 DBusCondVar*  (* DBusCondVarNewFunction)         (void);
00044 typedef void          (* DBusCondVarFreeFunction)        (DBusCondVar *cond);
00045 typedef void          (* DBusCondVarWaitFunction)        (DBusCondVar *cond,
00046                                                           DBusMutex   *mutex);
00047 typedef dbus_bool_t   (* DBusCondVarWaitTimeoutFunction) (DBusCondVar *cond,
00048                                                           DBusMutex   *mutex,
00049                                                           int          timeout_milliseconds);
00050 typedef void          (* DBusCondVarWakeOneFunction) (DBusCondVar *cond);
00051 typedef void          (* DBusCondVarWakeAllFunction) (DBusCondVar *cond);
00052 
00053 typedef enum 
00054 {
00055   DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK      = 1 << 0,
00056   DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK     = 1 << 1,
00057   DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK     = 1 << 2,
00058   DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK   = 1 << 3,
00059   DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK    = 1 << 4,
00060   DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK   = 1 << 5,
00061   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK   = 1 << 6,
00062   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK   = 1 << 7,
00063   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 << 8,
00064   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 << 9,
00065 
00066   DBUS_THREAD_FUNCTIONS_ALL_MASK     = (1 << 10) - 1
00067 } DBusThreadFunctionsMask;
00068 
00069 typedef struct
00070 {
00071   unsigned int mask;
00072 
00073   DBusMutexNewFunction mutex_new;
00074   DBusMutexFreeFunction mutex_free;
00075   DBusMutexLockFunction mutex_lock;
00076   DBusMutexUnlockFunction mutex_unlock;
00077 
00078   DBusCondVarNewFunction condvar_new;
00079   DBusCondVarFreeFunction condvar_free;
00080   DBusCondVarWaitFunction condvar_wait;
00081   DBusCondVarWaitTimeoutFunction condvar_wait_timeout;
00082   DBusCondVarWakeOneFunction condvar_wake_one;
00083   DBusCondVarWakeAllFunction condvar_wake_all;
00084   
00085   void (* padding1) (void);
00086   void (* padding2) (void);
00087   void (* padding3) (void);
00088   void (* padding4) (void);
00089   void (* padding5) (void);
00090   void (* padding6) (void);
00091   void (* padding7) (void);
00092   void (* padding8) (void);
00093   
00094 } DBusThreadFunctions;
00095 
00096 
00097 DBusMutex*   dbus_mutex_new            (void);
00098 void         dbus_mutex_free           (DBusMutex                 *mutex);
00099 dbus_bool_t  dbus_mutex_lock           (DBusMutex                 *mutex);
00100 dbus_bool_t  dbus_mutex_unlock         (DBusMutex                 *mutex);
00101 
00102 DBusCondVar* dbus_condvar_new          (void);
00103 void         dbus_condvar_free         (DBusCondVar               *cond);
00104 void         dbus_condvar_wait         (DBusCondVar               *cond,
00105                                         DBusMutex                 *mutex);
00106 dbus_bool_t  dbus_condvar_wait_timeout (DBusCondVar               *cond,
00107                                         DBusMutex                 *mutex,
00108                                         int                        timeout_milliseconds);
00109 void         dbus_condvar_wake_one     (DBusCondVar               *cond);
00110 void         dbus_condvar_wake_all     (DBusCondVar               *cond);
00111 
00112 dbus_bool_t  dbus_threads_init         (const DBusThreadFunctions *functions);
00113 
00114 
00115 
00116 DBUS_END_DECLS;
00117 
00118 #endif /* DBUS_THREADS_H */

Generated on Wed Oct 22 14:05:05 2003 for D-BUS by doxygen1.3-rc3