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

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.6     ! moko       10: volatile const char * IDENT_PA_THREADS_C="$Id: pa_threads.C,v 1.5 2017/02/07 22:00:45 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: pa_thread_t pa_get_thread_id() {
                     19:        return GetCurrentThreadId();
                     20: }
                     21: 
                     22: Mutex::Mutex() :
                     23:        handle(reinterpret_cast<uint>(CreateMutex(NULL, FALSE, 0))) {
                     24: }
                     25: 
                     26: Mutex::~Mutex() {
                     27:        CloseHandle(reinterpret_cast<HANDLE>(handle));
                     28: }
                     29: 
                     30: void Mutex::acquire() {
                     31:     WaitForSingleObject(reinterpret_cast<HANDLE>(handle), INFINITE);
                     32: }
                     33: 
                     34: void Mutex::release() {
                     35:     ReleaseMutex(reinterpret_cast<HANDLE>(handle));
                     36: }
                     37: 
                     38: #else
                     39: 
                     40: pa_thread_t pa_get_thread_id() { return 1; }
                     41: 
                     42: Mutex::Mutex() {}
                     43: Mutex::~Mutex() {}
                     44: void Mutex::acquire() {}
                     45: void Mutex::release() {}
                     46: 
                     47: #endif

E-mail: