Added the thread safe TSQueue and using it in mainwindow to replace the adhoc queue implementation.

This commit is contained in:
Eelke Klein 2017-01-03 07:22:36 +01:00
parent c551d982c6
commit 83064ab86b
10 changed files with 253 additions and 27 deletions

27
tsqueue.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef TSQUEUE_H
#define TSQUEUE_H
#include "Win32Event.h"
#include <deque>
#include <functional>
#include <mutex>
class TSQueue {
public:
using t_Callable = std::function<void()>;
TSQueue();
void add(t_Callable callable);
bool empty();
t_Callable pop();
HANDLE getNewDataEventHandle();
private:
using t_CallableQueue = std::deque<t_Callable>;
Win32Event newData;
std::mutex m;
t_CallableQueue futureQueue;
};
#endif // TSQUEUE_H