Event.h
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "os/ErrorCodes.h"
#include "os/Handle.h"
#include "os/WaitStatus.h"
#include "utils/NonCopyable.h"
namespace il2cpp
{
namespace os
{
class EventImpl;
class Event : public il2cpp::utils::NonCopyable
{
public:
Event(bool manualReset = false, bool signaled = false);
~Event();
ErrorCode Set();
ErrorCode Reset();
WaitStatus Wait(bool interruptible = false);
WaitStatus Wait(uint32_t ms, bool interruptible = false);
void* GetOSHandle();
private:
EventImpl* m_Event;
};
class EventHandle : public Handle
{
public:
EventHandle(Event* event)
: m_Event(event) {}
virtual ~EventHandle() { delete m_Event; }
virtual bool Wait() { m_Event->Wait(true); return true; }
virtual bool Wait(uint32_t ms) { return m_Event->Wait(ms, true) != kWaitStatusTimeout; }
virtual WaitStatus Wait(bool interruptible) { return m_Event->Wait(interruptible); }
virtual WaitStatus Wait(uint32_t ms, bool interruptible) { return m_Event->Wait(ms, interruptible); }
virtual void Signal() { m_Event->Set(); }
virtual void* GetOSHandle() { return m_Event->GetOSHandle(); }
Event& Get() { return *m_Event; }
private:
Event* m_Event;
};
}
}