Annotation of parser3/src/targets/apache13core/pa_threads.C, revision 1.5
1.2 paf 1: /** @file
2: Parser: Mutex realization class.
3:
1.5 ! paf 4: Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
6: */
7:
1.5 ! paf 8: static const char * const IDENT_THREADS_C="$Date: 2004/02/11 15:33:17 $";
1.2 paf 9:
10: #include "pa_threads.h"
11:
12: Mutex global_mutex;
13:
14: #ifdef WIN32
15:
16: #include <windows.h>
17:
18: const bool parser_multithreaded=true;
19:
20: pa_thread_t pa_get_thread_id() {
21: return GetCurrentThreadId();
22: }
23:
24: Mutex::Mutex() :
25: handle(reinterpret_cast<uint>(CreateMutex(NULL, FALSE, 0))) {
26: }
27:
28: Mutex::~Mutex() {
29: CloseHandle(reinterpret_cast<HANDLE>(handle));
30: }
31:
32: void Mutex::acquire() {
33: WaitForSingleObject(reinterpret_cast<HANDLE>(handle), INFINITE);
34: }
35:
36: void Mutex::release() {
37: ReleaseMutex(reinterpret_cast<HANDLE>(handle));
38: }
39:
40: #else
41:
42: const bool parser_multithreaded=false;
43:
44: pa_thread_t pa_get_thread_id() { return 1; }
45:
46: Mutex::Mutex() {}
47: Mutex::~Mutex() {}
48: void Mutex::acquire() {}
49: void Mutex::release() {}
50:
51: #endif
E-mail: