Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
win32event.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
12
#include "
core/types.h
"
13
14
//------------------------------------------------------------------------------
15
namespace
Win32
16
{
17
class
Win32Event
18
{
19
public
:
21
Win32Event
(
bool
manualReset=
false
);
23
Win32Event
(
Win32Event
&& rhs);
25
~Win32Event
();
26
28
void
Signal
();
30
void
Reset
();
32
void
Wait
()
const
;
34
bool
WaitTimeout
(
int
ms)
const
;
36
bool
Peek
()
const
;
38
bool
IsManual
()
const
;
39
40
private
:
41
bool
manual
;
42
HANDLE
event
;
43
};
44
45
//------------------------------------------------------------------------------
48
inline
49
Win32Event::Win32Event
(
bool
manualReset)
50
{
51
this->
event
=
CreateEvent
(NULL, manualReset, FALSE, NULL);
52
this->
manual
= manualReset;
53
n_assert
(0 != this->
event
);
54
}
55
56
//------------------------------------------------------------------------------
59
inline
60
Win32Event::Win32Event
(
Win32Event
&& rhs)
61
{
62
if
(this->
event
)
63
CloseHandle(this->
event
);
64
this->
event
= rhs.event;
65
this->
manual
= rhs.manual;
66
rhs.event =
nullptr
;
67
}
68
69
//------------------------------------------------------------------------------
72
inline
73
Win32Event::~Win32Event
()
74
{
75
if
(this->
event
!=
nullptr
)
76
{
77
CloseHandle(this->
event
);
78
this->
event
=
nullptr
;
79
}
80
}
81
82
//------------------------------------------------------------------------------
85
inline
void
86
Win32Event::Signal
()
87
{
88
SetEvent(this->
event
);
89
}
90
91
//------------------------------------------------------------------------------
94
inline
void
95
Win32Event::Reset
()
96
{
97
ResetEvent(this->
event
);
98
}
99
100
//------------------------------------------------------------------------------
103
inline
void
104
Win32Event::Wait
()
const
105
{
106
WaitForSingleObject(this->
event
, INFINITE);
107
}
108
109
//------------------------------------------------------------------------------
116
inline
bool
117
Win32Event::WaitTimeout
(
int
timeoutInMilliSec)
const
118
{
119
DWORD res = WaitForSingleObject(this->
event
, timeoutInMilliSec);
120
return
(WAIT_TIMEOUT == res) ? false :
true
;
121
}
122
123
//------------------------------------------------------------------------------
127
inline
bool
128
Win32Event::Peek
()
const
129
{
130
DWORD res = WaitForSingleObject(this->
event
, 0);
131
return
(WAIT_TIMEOUT == res) ? false :
true
;
132
}
133
134
//------------------------------------------------------------------------------
137
inline
bool
138
Win32Event::IsManual
()
const
139
{
140
return
this->
manual
;
141
}
142
143
}
// namespace Win32
144
//------------------------------------------------------------------------------
145
Win32::Win32Event::manual
bool manual
Definition
win32event.h:41
Win32::Win32Event::~Win32Event
~Win32Event()
destructor
Definition
win32event.h:73
Win32::Win32Event::event
HANDLE event
Definition
win32event.h:42
Win32::Win32Event::IsManual
bool IsManual() const
Returns true if event is manually reset.
Definition
win32event.h:138
Win32::Win32Event::Win32Event
Win32Event(bool manualReset=false)
constructor
Definition
win32event.h:49
Win32::Win32Event::Wait
void Wait() const
wait for the event to become signalled
Definition
win32event.h:104
Win32::Win32Event::Signal
void Signal()
signal the event
Definition
win32event.h:86
Win32::Win32Event::Peek
bool Peek() const
check if event is signalled
Definition
win32event.h:128
Win32::Win32Event::Reset
void Reset()
reset the event (only if manual reset)
Definition
win32event.h:95
Win32::Win32Event::WaitTimeout
bool WaitTimeout(int ms) const
wait for the event with timeout in millisecs
Definition
win32event.h:117
n_assert
#define n_assert(exp)
Definition
debug.h:50
CoreGraphics::CreateEvent
EventId CreateEvent(const EventCreateInfo &info)
create new event
Definition
vkevent.cc:42
Win32
[TODO: Describe Win32 subsystem]
types.h
code
foundation
threading
win32
win32event.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.