Annotation of parser3/src/targets/apache/pa_threads.C, revision 1.1
1.1 ! moko 1: /** @file
! 2: Parser: Mutex realization class.
! 3:
! 4: Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
! 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
! 6: */
! 7:
! 8: static const char * const IDENT_THREADS_C="$Date: 2006-04-09 13:38:47 $";
! 9:
! 10: #include "pa_threads.h"
! 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: