i6engine  1.0
ExceptionQueue.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_UTILS_EXCEPTIONS_EXCEPTIONQUEUE_H__
26 #define __I6ENGINE_UTILS_EXCEPTIONS_EXCEPTIONQUEUE_H__
27 
28 #include <functional>
29 #include <mutex>
30 #include <queue>
31 #include <vector>
32 
35 
36 namespace i6e {
37 namespace utils {
38 namespace exceptions {
39 
46  class ISIXE_UTILS_API ExceptionQueue : public Singleton<ExceptionQueue> {
47  friend class Singleton<ExceptionQueue>;
48 
49  public:
55  void enqueue(const loginfo & data);
56 
62  bool isEmpty() const;
63 
67  loginfo dequeue();
68 
72  void addCallback(const std::function<void(void)> & callback);
73 
74  private:
75  std::queue<loginfo> _queue;
76  mutable std::mutex _mutex;
77  std::vector<std::function<void(void)>> _callbacks;
78 
83  };
84 
85 } /* namespace exceptions */
86 } /* namespace utils */
87 } /* namespace i6e */
88 
89 #endif /* __I6ENGINE_UTILS_EXCEPTIONS_EXCEPTIONQUEUE_H__ */
90 
Internal data structure for exceptions.
Definition: Exceptions.h:79
Derive from this templated class to make a class a singleton. Refer to the Singleton Design Pattern i...
Definition: Singleton.h:44
Implements a queue that supports multiple producers but only one consumer.
#define ISIXE_UTILS_API