forked from ivansafrin/Polycode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolyThreaded.cpp
More file actions
39 lines (31 loc) · 787 Bytes
/
PolyThreaded.cpp
File metadata and controls
39 lines (31 loc) · 787 Bytes
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
#include "PolyThreaded.h"
#include "PolyCore.h"
using namespace Polycode;
Threaded::Threaded() : EventDispatcher() {
threadRunning = true;
scheduledForRemoval = false;
}
Threaded::~Threaded() {
core->removeThread(this);
}
void Threaded::killThread() {
threadRunning = false;
}
void Threaded::runThread(){
while(threadRunning) {
updateThread();
}
}
void Threaded::dispatchEvent(Event *event, int eventCode) {
core->lockMutex(eventMutex);
event->setEventCode(eventCode);
eventQueue.push_back(event);
core->unlockMutex(eventMutex);
}
void Threaded::dispatchEventNoDelete(Event *event, int eventCode) {
core->lockMutex(eventMutex);
event->setEventCode(eventCode);
event->deleteOnDispatch = false;
eventQueue.push_back(event);
core->unlockMutex(eventMutex);
}