LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
queuemanager.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <functional>
12#include <optional>
13#include <QObject>
14#include <QDateTime>
15#include <QPointer>
16#include <QPair>
17#include "sllconfig.h"
18
19class QTimer;
20
21namespace LC
22{
23namespace Util
24{
27 enum class QueuePriority
28 {
31 Normal,
32
35 High
36 };
37
43 class UTIL_SLL_API QueueManager : public QObject
44 {
45 Q_OBJECT
46
47 const int Timeout_;
48 QTimer * const ReqTimer_;
49 QDateTime LastRequest_;
50
51 bool Paused_;
52
53 typedef std::optional<QPointer<QObject>> OptionalTracker_t;
54 QList<QPair<std::function<void ()>, std::optional<QPointer<QObject>>>> Queue_;
55 public:
62 QueueManager (int timeout, QObject *parent = nullptr);
63
81 void Schedule (std::function<void ()> functor,
82 QObject *dependent = nullptr,
83 QueuePriority prio = QueuePriority::Normal);
84
90 void Clear ();
91
98 void Pause ();
99
106 bool IsPaused () const;
107
114 void Resume ();
115 private slots:
116 void exec ();
117 };
118}
119}
A simple scheduling manager for a queue of functors.
QueuePriority
The priority of the action in the queue.
@ High
Higher priority.
@ Normal
Standard priority.
Definition constants.h:15
#define UTIL_SLL_API
Definition sllconfig.h:16