libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
IQueueBase.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef IQUEUEBASE_H_
32 #define IQUEUEBASE_H_
33 
34 #include "Output/Output.h"
35 
36 #include <atomic>
37 #include <memory>
38 #include <condition_variable>
39 #include <thread>
40 #include <vector>
41 
42 namespace BaseLib {
43 class SharedObjects;
44 
45 class IQueueBase {
46  public:
47  IQueueBase(SharedObjects *baseLib, uint32_t queueCount);
48  virtual ~IQueueBase() {}
49 
56  void printQueueFullError(BaseLib::Output &out, const std::string &message);
57  protected:
58  SharedObjects *_bl = nullptr;
59  int32_t _queueCount = 2;
60  std::unique_ptr<std::atomic_bool[]> _stopProcessingThread;
61 
62  std::atomic<uint32_t> _droppedEntries{0};
63  std::atomic<int64_t> _lastQueueFullError{0};
64 };
65 
66 }
67 #endif
virtual ~IQueueBase()
Definition: IQueueBase.h:48
This is the base library main class.
Definition: BaseLib.h:95
Definition: IQueueBase.h:45
Definition: BaseLib.cpp:34
Class to print output of different kinds to the standard and error output.
Definition: Output.h:54
IQueueBase(SharedObjects *baseLib, uint32_t queueCount)
Definition: IQueueBase.cpp:36
int32_t _queueCount
Definition: IQueueBase.h:59
std::atomic< int64_t > _lastQueueFullError
Definition: IQueueBase.h:63
std::atomic< uint32_t > _droppedEntries
Definition: IQueueBase.h:62
std::unique_ptr< std::atomic_bool[]> _stopProcessingThread
Definition: IQueueBase.h:60
void printQueueFullError(BaseLib::Output &out, const std::string &message)
Prints a rate limited (1 output per 10 seconds) error message and keeps count of error messages...
Definition: IQueueBase.cpp:42
SharedObjects * _bl
Definition: IQueueBase.h:58