ETL
0.04.19
Main Page
Related Pages
Classes
Files
File List
File Members
ETL
_mutex_win32.h
Go to the documentation of this file.
1
25
/* === S T A R T =========================================================== */
26
27
#ifndef __ETL__MUTEX_WIN32_H_
28
#define __ETL__MUTEX_WIN32_H_
29
30
/* === H E A D E R S ======================================================= */
31
32
#include <windows.h>
33
// extern HANDLE CreateMutex(NULL, FALSE, NULL);
34
// extern CloseHandle(handle);
35
// extern WaitForSingleObject(handle, INFINITE);
36
// extern ReleaseMutex(handle);
37
38
/* === M A C R O S ========================================================= */
39
40
41
/* === C L A S S E S & S T R U C T S ======================================= */
42
43
_ETL_BEGIN_NAMESPACE
44
45
class
mutex
46
{
47
HANDLE
handle
;
48
public
:
49
50
mutex
()
51
{
handle
= CreateMutex(
NULL
, FALSE,
NULL
); }
52
53
~mutex
()
54
{ CloseHandle(
handle
); }
55
57
class
lock
58
{
59
mutex
*
_mtx
;
60
public
:
61
lock
(
mutex
&x):
_mtx
(&x) {
_mtx
->
lock_mutex
(); }
62
~lock
() {
_mtx
->
unlock_mutex
(); }
63
mutex
&
get
() {
return
*
_mtx
; }
64
};
65
66
void
lock_mutex
(
void
)
67
{ WaitForSingleObject(
handle
, INFINITE); }
68
69
bool
try_lock_mutex
(
void
)
70
{
return
WaitForSingleObject(
handle
, INFINITE)==WAIT_FAILED; }
71
72
void
unlock_mutex
(
void
)
73
{ ReleaseMutex(
handle
); }
74
};
75
76
_ETL_END_NAMESPACE
77
78
/* === E X T E R N S ======================================================= */
79
80
/* === E N D =============================================================== */
81
82
#endif
Generated on Mon Nov 16 2015 15:32:03 for ETL by
1.8.1.2