Signapse
src
SchedulableLink.cpp
Go to the documentation of this file.
1
#include "
SchedulableLink.h
"
2
#include "
BlockingQueue.cpp
"
3
4
8
void
SchedulableLink::Run
(){
9
//waits for scenes to appear on the scheduleQueue,
10
while
(
isOn
){
11
Scene
s =
scheduleQueue
.
Pop
();
//Blocking Queue Sleeps Execution Until Scene arrives
12
Scene
out =
ProcessScene
(s);
13
if
(!
sceneCallback
)
continue
;
14
sceneCallback
->
NextScene
(out);
15
}
16
}
21
void
SchedulableLink::Enqueue
(
Scene
s) {
22
scheduleQueue
.
Push
(s);
23
}
27
bool
SchedulableLink::Available
() {
28
return
scheduleQueue
.
IsEmpty
();
//singly threaded for now
29
}
30
34
void
SchedulableLink::Start
() {
35
scheduleWorker
= std::thread(&
SchedulableLink::Run
,
this
);
36
}
40
void
SchedulableLink::Stop
(){
41
isOn
=
false
;
42
scheduleWorker
.join();
43
}
48
void
SchedulableLink::NextScene
(
Scene
scene) {
49
//if space on schedule queue, add this scene; otherwise pass the scene through
50
if
(
scheduleQueue
.
IsEmpty
()) {
//singly threaded for now
51
scheduleQueue
.
Push
(scene);
52
}
53
}
54
BlockingQueue.cpp
SchedulableLink.h
BlockingQueue::Push
void Push(T toPush)
Definition:
BlockingQueue.cpp:44
BlockingQueue::Pop
T Pop()
Definition:
BlockingQueue.cpp:11
BlockingQueue::IsEmpty
bool IsEmpty()
Definition:
BlockingQueue.cpp:24
PipelineLink::sceneCallback
SceneCallback * sceneCallback
Definition:
PipelineLink.h:16
SceneCallback::NextScene
virtual void NextScene(Scene next)=0
SchedulableLink::Enqueue
void Enqueue(Scene s)
Definition:
SchedulableLink.cpp:21
SchedulableLink::NextScene
void NextScene(Scene s)
Definition:
SchedulableLink.cpp:48
SchedulableLink::Run
void Run()
Definition:
SchedulableLink.cpp:8
SchedulableLink::ProcessScene
virtual Scene ProcessScene(Scene s)=0
SchedulableLink::Stop
void Stop()
Definition:
SchedulableLink.cpp:40
SchedulableLink::scheduleWorker
std::thread scheduleWorker
Definition:
SchedulableLink.h:29
SchedulableLink::Start
void Start()
Definition:
SchedulableLink.cpp:34
SchedulableLink::Available
bool Available()
Definition:
SchedulableLink.cpp:27
SchedulableLink::isOn
bool isOn
Definition:
SchedulableLink.h:28
SchedulableLink::scheduleQueue
BlockingQueue< Scene > scheduleQueue
Definition:
SchedulableLink.h:27
Scene
Struct Scene.
Definition:
Scene.h:36
Generated by
1.9.3