Annotation of parser3/src/targets/apache/pa_threads.C, revision 1.2

1.1       moko        1: /** @file
                      2:        Parser: Mutex realization class.
                      3: 
1.2     ! moko        4:        Copyright (c) 2001-2012 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.2     ! moko       10: volatile const char * IDENT_PA_THREADS_C="$Id: 2010-11-13 00:43:22 $" IDENT_PA_THREADS_H;
1.1       moko       11: 
                     12: Mutex global_mutex;
                     13: 
                     14: #ifdef WIN32
                     15: 
                     16: #define  WINVER  0x0400
                     17: #include <windows.h>
                     18: 
                     19: const bool parser_multithreaded=true;
                     20: 
                     21: pa_thread_t pa_get_thread_id() {
                     22:        return GetCurrentThreadId();
                     23: }
                     24: 
                     25: Mutex::Mutex() :
                     26:        handle(reinterpret_cast<uint>(CreateMutex(NULL, FALSE, 0))) {
                     27: }
                     28: 
                     29: Mutex::~Mutex() {
                     30:        CloseHandle(reinterpret_cast<HANDLE>(handle));
                     31: }
                     32: 
                     33: void Mutex::acquire() {
                     34:     WaitForSingleObject(reinterpret_cast<HANDLE>(handle), INFINITE);
                     35: }
                     36: 
                     37: void Mutex::release() {
                     38:     ReleaseMutex(reinterpret_cast<HANDLE>(handle));
                     39: }
                     40: 
                     41: #else
                     42: 
                     43: const bool parser_multithreaded=false;
                     44: 
                     45: pa_thread_t pa_get_thread_id() { return 1; }
                     46: 
                     47: Mutex::Mutex() {}
                     48: Mutex::~Mutex() {}
                     49: void Mutex::acquire() {}
                     50: void Mutex::release() {}
                     51: 
                     52: #endif

E-mail: