ROOT
6.07/09
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
core
thread
src
TWin32Mutex.cxx
Go to the documentation of this file.
1
// @(#)root/thread:$Id$
2
// Author: Bertrand Bellenot 23/10/04
3
4
/*************************************************************************
5
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
7
* *
8
* For the licensing terms see $ROOTSYS/LICENSE. *
9
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10
*************************************************************************/
11
12
//////////////////////////////////////////////////////////////////////////
13
// //
14
// TWin32Mutex //
15
// //
16
// This class provides an interface to the Win32 mutex routines. //
17
// //
18
//////////////////////////////////////////////////////////////////////////
19
20
#ifndef _WIN32_WINNT
21
#define _WIN32_WINNT 0x0501 // needed for TryEnterCriticalSection
22
#endif
23
24
#include "
TThread.h
"
25
#include "
TWin32Mutex.h
"
26
27
ClassImp
(
TWin32Mutex
)
28
29
////////////////////////////////////////////////////////////////////////////////
30
/// Create a Win32 mutex lock.
31
32
TWin32Mutex
::
TWin32Mutex
(
Bool_t
recursive) :
TMutexImp
()
33
{
34
::InitializeCriticalSection(&fCritSect);
35
}
36
37
////////////////////////////////////////////////////////////////////////////////
38
/// TMutex dtor.
39
40
TWin32Mutex::~TWin32Mutex
()
41
{
42
::DeleteCriticalSection(&
fCritSect
);
43
}
44
45
////////////////////////////////////////////////////////////////////////////////
46
/// Lock the mutex.
47
48
Int_t
TWin32Mutex::Lock
()
49
{
50
::EnterCriticalSection(&
fCritSect
);
51
return
0;
52
}
53
54
////////////////////////////////////////////////////////////////////////////////
55
/// Try locking the mutex. Returns 0 if mutex can be locked.
56
57
Int_t
TWin32Mutex::TryLock
()
58
{
59
if
(::TryEnterCriticalSection(&
fCritSect
))
60
return
0;
61
return
1;
62
}
63
64
////////////////////////////////////////////////////////////////////////////////
65
/// Unlock the mutex.
66
67
Int_t
TWin32Mutex::UnLock
(
void
)
68
{
69
::LeaveCriticalSection(&
fCritSect
);
70
return
0;
71
}
TWin32Mutex::UnLock
Int_t UnLock()
Unlock the mutex.
Definition:
TWin32Mutex.cxx:67
TWin32Mutex::Lock
Int_t Lock()
Lock the mutex.
Definition:
TWin32Mutex.cxx:48
Int_t
int Int_t
Definition:
RtypesCore.h:41
Bool_t
bool Bool_t
Definition:
RtypesCore.h:59
TWin32Mutex::fCritSect
CRITICAL_SECTION fCritSect
Definition:
TWin32Mutex.h:39
TWin32Mutex.h
TWin32Mutex
Definition:
TWin32Mutex.h:34
TWin32Mutex::TryLock
Int_t TryLock()
Try locking the mutex. Returns 0 if mutex can be locked.
Definition:
TWin32Mutex.cxx:57
TThread.h
ClassImp
#define ClassImp(name)
Definition:
Rtypes.h:279
TWin32Mutex::~TWin32Mutex
virtual ~TWin32Mutex()
TMutex dtor.
Definition:
TWin32Mutex.cxx:40
TMutexImp
Definition:
TMutexImp.h:33