blob: 08c31f1eb7d2249b0e1ef4b16c1dbf039f935643 [file] [log] [blame]
Owen Anderson0c2185a2009-06-16 20:19:28 +00001//= llvm/System/Win32/Mutex.inc - Win32 Reader/Writer Mutual Exclusion Lock =//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Win32 specific (non-pthread) RWMutex class.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only generic Win32 code that
16//=== is guaranteed to work on *all* Win32 variants.
17//===----------------------------------------------------------------------===//
18
19#include "Win32.h"
20
21namespace llvm {
22using namespace sys;
23
24RWMutex::RWMutex() {
25 data_ = new PSRWLOCK;
26 InitializeSRWLock((PSRWLOCK*)data_);
27}
28
29RWMutex::~RWMutex() {
30 delete (PSRWLOCK*)data_;
31 data_ = 0;
32}
33
34bool RWMutex::reader_acquire() {
35 AcquireSRWLockShared((PSRWLOCK*)data_);
36 return true;
37}
38
39bool RWMutex::reader_release() {
40 ReleaseSRWLockShared((PSRWLOCK*)data_);
41 return true;
42}
43
44bool RWMutex::writer_acquire() {
45 AcquireSRWLockExclusive((PSRWLOCK*)data_);
46 return true;
47}
48
49bool RWMutex::writer_release() {
50 ReleaseSRWLockExclusive((PSRWLOCK*)data_);
51 return true;
52}
53
54
55}