-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathThreadManager.h
More file actions
64 lines (47 loc) · 1.17 KB
/
ThreadManager.h
File metadata and controls
64 lines (47 loc) · 1.17 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
59
60
61
62
63
64
#ifndef __ThreadManager__
#define __ThreadManager__
#include "TOP_CPlusPlusBase.h"
#include <mutex>
#include <atomic>
#include <condition_variable>
#include <thread>
using namespace TD;
// class Parameters;
class OP_Inputs;
enum class ThreadStatus
{
Busy,
Ready,
Done,
Waiting
};
class ThreadManager
{
public:
ThreadManager();
~ThreadManager();
void sync(bool doDither, int bitsPerColor, int inWidth, int inHeight, const OP_SmartRef<OP_TOPDownloadResult> downRes, TD::TOP_Context* context);
void popOutBuffer(OP_SmartRef<TOP_Buffer>& outBuffer, TD::TOP_UploadInfo& info);
ThreadStatus getStatus();
private:
void threadFn();
std::atomic<ThreadStatus> myStatus;
// Out buffer resource
OP_SmartRef<OP_TOPDownloadResult> myDownRes;
OP_SmartRef<TOP_Buffer> myOutBuffer;
// Thread and Sync variables
std::thread* myThread;
std::mutex myBufferMutex;
std::condition_variable myBufferCV;
std::atomic_bool myThreadShouldExit;
// Parameters saved
int myInWidth;
int myInHeight;
int myOutWidth;
int myOutHeight;
bool myDoDither;
int myBitsPerColor;
TD::TOP_Context* myContext;
TD::TOP_UploadInfo myUploadInfo;
};
#endif