Annotation of parser3/src/targets/apache/pa_threads.C, revision 1.5
1.1 moko 1: /** @file
2: Parser: Mutex realization class.
3:
1.5 ! moko 4: Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com)
1.1 moko 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
6: */
7:
1.2 moko 8: #include "pa_threads.h"
1.1 moko 9:
1.5 ! moko 10: volatile const char * IDENT_PA_THREADS_C="$Id: pa_threads.C,v 1.4 2015/10/26 01:21:59 moko Exp $" IDENT_PA_THREADS_H;
1.1 moko 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: