Signapse
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SchedulableLink Class Referenceabstract

#include <SchedulableLink.h>

Inheritance diagram for SchedulableLink:
Inheritance graph
Collaboration diagram for SchedulableLink:
Collaboration graph

Public Member Functions

void NextScene (Scene s)
 
virtual Scene ProcessScene (Scene s)=0
 
void Start ()
 
void Stop ()
 
bool Available ()
 
virtual void NextScene (Scene next)=0
 

Protected Member Functions

void Enqueue (Scene s)
 
void Run ()
 
void NextScene (Scene scene)
 

Protected Attributes

BlockingQueue< ScenescheduleQueue
 
bool isOn = true
 
std::thread scheduleWorker
 

Detailed Description

A class which extends PipelineLink to handle latency-bound stages. The NextScene function is inherited to add Scenes to an internal BlockingQueue. The pure virtual function ProcessScene must be implemented by derived classes to define Scene processing behaviour. The Run method is called in a separate thread and handles waking up the thread when scenes are available and calling back to the next pipeline element. BlockingQueue is used as a scheduling mechanism for future extension to multithreading.

Definition at line 17 of file SchedulableLink.h.

Member Function Documentation

◆ Available()

bool SchedulableLink::Available ( )
Returns
true if the scheduleQueue is empty; false otherwise.

Definition at line 27 of file SchedulableLink.cpp.

27 {
28 return scheduleQueue.IsEmpty(); //singly threaded for now
29}

◆ Enqueue()

void SchedulableLink::Enqueue ( Scene  s)
protected

Adds a scene to the intenal scheduleQueue

Parameters
s

Definition at line 21 of file SchedulableLink.cpp.

21 {
23}
void Push(T toPush)

◆ NextScene()

void SchedulableLink::NextScene ( Scene  scene)
virtual

If space is available on the scheduleQueue, add the scene to the queue. Otherwise skip.

Parameters
scene

Reimplemented from PipelineLink.

Definition at line 48 of file SchedulableLink.cpp.

48 {
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}

◆ ProcessScene()

virtual Scene SchedulableLink::ProcessScene ( Scene  s)
pure virtual

Implemented in CNNProcessor.

◆ Run()

void SchedulableLink::Run ( )
protected

Looping process to process scenes and call-back to next pipeline element. Worker thread is slept while no elements are available using BlockingQueue functionality

Definition at line 8 of file SchedulableLink.cpp.

8 {
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;
15 }
16}
virtual void NextScene(Scene next)=0
Struct Scene.
Definition: Scene.h:36

◆ Start()

void SchedulableLink::Start ( )

Starts execution with the worker thread.

Definition at line 34 of file SchedulableLink.cpp.

34 {
35 scheduleWorker = std::thread(&SchedulableLink::Run, this);
36}

◆ Stop()

void SchedulableLink::Stop ( )

Turns off the link, kills worker thread. Must be called to release thread resources.

Definition at line 40 of file SchedulableLink.cpp.

40 {
41 isOn = false;
42 scheduleWorker.join();
43}

Member Data Documentation

◆ isOn

bool SchedulableLink::isOn = true
protected

Definition at line 28 of file SchedulableLink.h.

◆ scheduleQueue

BlockingQueue<Scene> SchedulableLink::scheduleQueue
protected

Definition at line 27 of file SchedulableLink.h.

◆ scheduleWorker

std::thread SchedulableLink::scheduleWorker
protected

Definition at line 29 of file SchedulableLink.h.


The documentation for this class was generated from the following files: