11bad4f09e305606555a5f4930d5ebfe4b7d85ce
[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 #elif defined(HAVE_DB4_DB_H)
17 #include <db4/db.h>
18 #else
19 #error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
20 #endif
21
22 #include "server.h"
23 #include "sysdep_decls.h"
24
25 /*
26  * Things we need to keep track of per-thread instead of per-session
27  */
28 struct thread_tsd {
29         DB_TXN *tid;            /* Transaction handle */
30         DBC *cursors[MAXCDB];   /* Cursors, for traversals... */
31 };
32
33 extern struct thread_tsd masterTSD;
34 #define TSD MyThread()
35
36 extern int num_workers;
37 extern int active_workers;
38 extern int server_shutting_down;
39
40 struct thread_tsd *MyThread(void);
41 int try_critical_section (int which_one);
42 void begin_critical_section (int which_one);
43 void end_critical_section (int which_one);
44 void go_threading(void);
45 void InitializeMasterTSD(void);
46 void CtdlThreadCreate(void *(*start_routine)(void*));
47
48
49 extern pthread_mutex_t ThreadCountMutex;;
50
51 #endif // THREADS_H