Annotation of parser3/src/include/pa_threads.h, revision 1.3
1.1 paf 1: /*
1.3 ! paf 2: $Id: pa_threads.h,v 1.2 2001/01/29 11:53:42 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_THREADS_H
6: #define PA_THREADS_H
7:
8: #ifdef HAVE_CONFIG_H
9: # include "pa_config.h"
10: #endif
11:
12: #include "pa_types.h"
13:
14:
15: #ifdef MULTITHREAD
16:
17: class Mutex {
18: uint handle;
19: public:
20: Mutex();
21: ~Mutex();
1.2 paf 22: void acquire();
23: void release();
1.1 paf 24: };
25:
1.2 paf 26: extern Mutex global_mutex;
1.1 paf 27:
1.2 paf 28: class AutoSYNCHRONIZED {
1.3 ! paf 29: bool thread_safe;
1.2 paf 30: public:
1.3 ! paf 31: AutoSYNCHRONIZED(bool athread_safe) : thread_safe(athread_safe) {
! 32: if(thread_safe)
! 33: global_mutex.acquire();
! 34: }
! 35: ~AutoSYNCHRONIZED() {
! 36: if(thread_safe)
! 37: global_mutex.release();
! 38: }
1.2 paf 39: }
40:
1.3 ! paf 41: #define SYNCHRONIZED(thread_safe) AutoSYNCHRONIZED autoSYNCHRONIZED(thread_safe)
1.2 paf 42:
43:
44: #else // not MULTITHREAD-ed
45:
1.3 ! paf 46: #define SYNCHRONIZED(thread_safe) /* do nothing */
1.1 paf 47:
48: #endif
1.2 paf 49:
1.1 paf 50:
51: #endif
E-mail: