blob: c72646a8a3c99351ffcfcdbd3ab12d4f509d6e6b (
plain)
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
|
#include "events.h"
void EventQueue::post(Event *event, timepos_t time)
{
MutexAutolock lock(mutex);
event->offset = time;
queue.insert(std::pair<timepos_t, Event*>(time, event));
}
Event *EventQueue::take(timepos_t time)
{
MutexAutolock lock(mutex);
std::multimap<timepos_t, Event*>::iterator i = queue.find(time);
if(i == queue.end()) return NULL;
Event *event = i->second;
queue.erase(i);
return event;
}
bool EventQueue::hasEvent(timepos_t time)
{
MutexAutolock lock(mutex);
return queue.find(time) != queue.end();
}
|