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

View file

@ -1,6 +1,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "tsqueue.h"
#include <QMainWindow>
#include <QSocketNotifier>
#include <memory>
@ -36,20 +37,16 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
using callable = std::function<void()>;
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
/* Meant to be called from other threads to pass a code block
* that has to be executed in the context of the thread of the window.
*/
void QueueTask(callable c);
void QueueTask(TSQueue::t_Callable c);
private:
using t_CallableQueue = std::deque<callable>;
std::mutex m_mutexCallableQueue;
t_CallableQueue m_callableQueue;
TSQueue m_taskQueue;
std::unique_ptr<Ui::MainWindow> ui;