|
|
| version 1.4, 2001/10/31 11:23:39 | version 1.22, 2017/02/07 22:00:45 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: zero Mutex realization class. | Parser: zero Mutex realization class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | |
| */ | */ |
| #include "pa_threads.h" | #include "pa_threads.h" |
| /// @test really? | volatile const char * IDENT_PA_THREADS_C="$Id$" IDENT_PA_THREADS_H; |
| const bool parser_multithreaded=false; | |
| #include <windows.h> | |
| const bool parser_multithreaded=true; | |
| pa_thread_t pa_get_thread_id() { | |
| return GetCurrentThreadId(); | |
| } | |
| Mutex global_mutex; | Mutex global_mutex; |
| Mutex::Mutex() { | Mutex::Mutex() : |
| handle(reinterpret_cast<uint>(CreateMutex(NULL, FALSE, 0))) { | |
| } | } |
| Mutex::~Mutex() { | Mutex::~Mutex() { |
| CloseHandle(reinterpret_cast<HANDLE>(handle)); | |
| } | } |
| void Mutex::acquire() { | void Mutex::acquire() { |
| WaitForSingleObject(reinterpret_cast<HANDLE>(handle), INFINITE); | |
| } | } |
| void Mutex::release() { | void Mutex::release() { |
| ReleaseMutex(reinterpret_cast<HANDLE>(handle)); | |
| } | } |