00001 /* 00002 * Copyright (c) 2008-2009 Niels Provos and Nick Mathewson 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 1. Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * 2. Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * 3. The name of the author may not be used to endorse or promote products 00013 * derived from this software without specific prior written permission. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00017 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00019 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00020 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00021 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00022 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00024 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 #ifndef _EVENT2_THREAD_H_ 00027 #define _EVENT2_THREAD_H_ 00028 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 #include <event-config.h> 00061 00062 /* combine (lock|unlock) with (read|write) */ 00063 #define EVTHREAD_LOCK 0x01 00064 #define EVTHREAD_UNLOCK 0x02 00065 #define EVTHREAD_WRITE 0x04 00066 #define EVTHREAD_READ 0x08 00067 00080 void evthread_set_lock_create_callbacks( 00081 void *(*alloc_fn)(void), void (*free_fn)(void *)); 00082 00090 void evthread_set_locking_callback( 00091 void (*locking_fn)(int mode, void *lock)); 00092 00100 void evthread_set_id_callback( 00101 unsigned long (*id_fn)(void)); 00102 00107 int evthread_make_base_notifiable(struct event_base *base); 00108 00109 #ifdef WIN32 00110 00114 int evthread_use_windows_threads(void); 00115 #endif 00116 00117 #ifdef _EVENT_HAVE_PTHREADS 00118 00123 int evthread_use_pthreads(void); 00124 #endif 00125 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 00130 #endif /* _EVENT2_THREAD_H_ */