00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EVENT2_THREAD_H_INCLUDED_
00027 #define EVENT2_THREAD_H_INCLUDED_
00028
00049 #include <event2/visibility.h>
00050
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054
00055 #include <event2/event-config.h>
00056
00064 #define EVTHREAD_WRITE 0x04
00065
00067 #define EVTHREAD_READ 0x08
00068
00071 #define EVTHREAD_TRY 0x10
00072
00074 #if !defined(EVENT__DISABLE_THREAD_SUPPORT) || defined(EVENT_IN_DOXYGEN_)
00075
00076 #define EVTHREAD_LOCK_API_VERSION 1
00077
00085 #define EVTHREAD_LOCKTYPE_RECURSIVE 1
00086
00087
00088 #define EVTHREAD_LOCKTYPE_READWRITE 2
00089
00095 struct evthread_lock_callbacks {
00098 int lock_api_version;
00106 unsigned supported_locktypes;
00109 void *(*alloc)(unsigned locktype);
00112 void (*free)(void *lock, unsigned locktype);
00115 int (*lock)(unsigned mode, void *lock);
00118 int (*unlock)(unsigned mode, void *lock);
00119 };
00120
00129 EVENT2_EXPORT_SYMBOL
00130 int evthread_set_lock_callbacks(const struct evthread_lock_callbacks *);
00131
00132 #define EVTHREAD_CONDITION_API_VERSION 1
00133
00134 struct timeval;
00135
00140 struct evthread_condition_callbacks {
00143 int condition_api_version;
00148 void *(*alloc_condition)(unsigned condtype);
00150 void (*free_condition)(void *cond);
00157 int (*signal_condition)(void *cond, int broadcast);
00168 int (*wait_condition)(void *cond, void *lock,
00169 const struct timeval *timeout);
00170 };
00171
00180 EVENT2_EXPORT_SYMBOL
00181 int evthread_set_condition_callbacks(
00182 const struct evthread_condition_callbacks *);
00183
00191 EVENT2_EXPORT_SYMBOL
00192 void evthread_set_id_callback(
00193 unsigned long (*id_fn)(void));
00194
00195 #if (defined(_WIN32) && !defined(EVENT__DISABLE_THREAD_SUPPORT)) || defined(EVENT_IN_DOXYGEN_)
00196
00200 EVENT2_EXPORT_SYMBOL
00201 int evthread_use_windows_threads(void);
00205 #define EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 1
00206 #endif
00207
00208 #if defined(EVENT__HAVE_PTHREADS) || defined(EVENT_IN_DOXYGEN_)
00209
00214 EVENT2_EXPORT_SYMBOL
00215 int evthread_use_pthreads(void);
00217 #define EVTHREAD_USE_PTHREADS_IMPLEMENTED 1
00218
00219 #endif
00220
00227 EVENT2_EXPORT_SYMBOL
00228 void evthread_enable_lock_debugging(void);
00229
00230
00231
00232 EVENT2_EXPORT_SYMBOL
00233 void evthread_enable_lock_debuging(void);
00234
00235 #endif
00236
00237 struct event_base;
00246 EVENT2_EXPORT_SYMBOL
00247 int evthread_make_base_notifiable(struct event_base *base);
00248
00249 #ifdef __cplusplus
00250 }
00251 #endif
00252
00253 #endif