28f73b520f5dc2278d6e36557a230b356a8d5968
[citadel.git] / citadel / threads.h
1
2 #ifndef THREADS_H
3 #define THREADS_H
4
5 #include "sysdep.h"
6
7 #ifdef HAVE_PTHREAD_H
8 #include <pthread.h>
9 #endif
10
11 #include <sys/time.h>
12 #include <string.h>
13
14 #ifdef HAVE_DB_H
15 #include <db.h>
16 #error <db.h> was not found by configure. Install the Berkeley DB development package.
17 #endif
18
19 #include "server.h"
20 #include "sysdep_decls.h"
21
22 /*
23  * Things we need to keep track of per-thread instead of per-session
24  */
25 struct thread_tsd {
26         DB_TXN *tid;            /* Transaction handle */
27         DBC *cursors[MAXCDB];   /* Cursors, for traversals... */
28 };
29
30 extern struct thread_tsd masterTSD;
31 #define TSD MyThread()
32
33 extern int num_workers;
34 extern int active_workers;
35 extern int server_shutting_down;
36
37 struct thread_tsd *MyThread(void);
38 int try_critical_section (int which_one);
39 void begin_critical_section (int which_one);
40 void end_critical_section (int which_one);
41 void go_threading(void);
42 void InitializeMasterTSD(void);
43 void CtdlThreadCreate(void *(*start_routine)(void*));
44
45
46 extern pthread_mutex_t ThreadCountMutex;;
47
48 #endif // THREADS_H