-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThread.h
More file actions
58 lines (50 loc) · 1.43 KB
/
Thread.h
File metadata and controls
58 lines (50 loc) · 1.43 KB
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
/*
* Thread.h
*
* Created on: Jan 18, 2016
* Author: sabeyruw
*/
#ifndef THREAD_H_
#define THREAD_H_
#include "Vector.h"
class Thread
{
public:
const char* threadName;
int threadIndex;
int threadPriority;
bool isActive;
typedef Vector<Node*> NodeVector;
//-- Intermediate vectors
NodeVector graphStructureVector;
NodeVector transferredVector;
NodeVector topoQueue;
//-- Operation vector
NodeVector operationVector;
//-- Transfer objects between threads
unsigned char* buffer;
#if !defined(EMBEDDED_MODE)
enum { BUFFER_SIZE = 512 }; // some storage capacity (bytes)
#endif
Thread(const char* threadName, const int& threadPriority, const int& threadIndex) :
threadName(threadName), threadIndex(threadIndex), threadPriority(threadPriority), isActive(false), buffer(0)
{
#if !defined(EMBEDDED_MODE)
buffer = new unsigned char[BUFFER_SIZE];
#endif
}
virtual ~Thread()
{
for (NodeVector::iterator iter = transferredVector.begin();
iter != transferredVector.end(); ++iter)
delete *iter;
graphStructureVector.clear();
transferredVector.clear();
topoQueue.clear();
operationVector.clear();
#if !defined(EMBEDDED_MODE)
delete[] buffer;
#endif
}
};
#endif /* THREAD_H_ */