-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvent.cpp
113 lines (87 loc) · 1.66 KB
/
Event.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include"BaseLib/Event.h"
namespace BaseLib { namespace Concurrent
{
Event::Event(EventData::Ptr eventData, Templates::Any eventId)
: Function(eventId)
, source_()
, eventData_(eventData)
, stackTrace_("")
{ }
Event::~Event()
{ }
Event::Ptr Event::GetPtr()
{
return shared_from_this();
}
// --------------------------
// wait for event delivery. Do I need an EventResult?
// --------------------------
bool Event::WaitFor(int64 msecs) const
{
Locker locker(this);
return waitForReceived<Status::EventStatus>(&status_, msecs);
}
void Event::AddResult(Templates::Any val)
{
Locker lock(this);
results_.push_back(val);
}
// --------------------------
// For filtering
// --------------------------
void Event::Accept()
{
Locker locker(this);
status_.Accept();
this->wakeAll();
}
void Event::Ignore()
{
Locker locker(this);
status_.Ignore();
this->wakeAll();
}
void Event::Filter()
{
Locker locker(this);
status_.Filter();
this->wakeAll();
}
void Event::Reject()
{
Locker locker(this);
status_.Reject();
this->wakeAll();
}
bool Event::IsAccepted() const
{
return status_.IsAccepted();
}
bool Event::IsReceived() const
{
return status_.IsReceived();
}
bool Event::IsApplicationEvent() const
{
return true;
}
// --------------------------
// Status and identification
// --------------------------
Templates::Any Event::EventId() const
{
return this->Id();
}
const Status::EventStatus &Event::Status() const
{
return status_;
}
EventData::Ptr Event::Data() const
{
return eventData_;
}
BaseLib::GeneralException Event::Exception() const
{
return stackTrace_;
}
}}