LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 
19 class QTimer;
20 
21 namespace LC
22 {
23 namespace 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,
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 }
sllconfig.h
LC::Util::QueuePriority::Normal
@ Normal
Standard priority.
QList
Definition: ianrulesstorage.h:14
UTIL_SLL_API
#define UTIL_SLL_API
Definition: sllconfig.h:16
LC::Util::QueuePriority
QueuePriority
The priority of the action in the queue.
Definition: queuemanager.h:27
LC::Util::QueueManager
A simple scheduling manager for a queue of functors.
Definition: queuemanager.h:43
LC::Util::QueuePriority::High
@ High
Higher priority.
LC
Definition: constants.h:14