YAMI4 C++
incoming_message_queue.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICPP_INCOMING_MESSAGE_QUEUE_H_INCLUDED
18 #define YAMICPP_INCOMING_MESSAGE_QUEUE_H_INCLUDED
19 
20 #include "incoming_message_info.h"
21 #include <deque>
22 #include <memory>
23 
24 // selected per platform
25 #include <mutex.h>
26 #include <semaphore.h>
27 
28 namespace yami
29 {
30 
31 namespace details
32 {
33 
34 class incoming_message_queue
35 {
36 public:
37  incoming_message_queue();
38  ~incoming_message_queue();
39 
40  void push(std::unique_ptr<incoming_message_info> & incoming);
41 
42  std::unique_ptr<incoming_message_info> pop();
43 
44 private:
45  incoming_message_queue(const incoming_message_queue &);
46  void operator=(const incoming_message_queue &);
47 
48  typedef std::deque<incoming_message_info *> queue_type;
49 
50  queue_type queue_;
51  bool terminated_;
52  semaphore sem_;
53  mutex mtx_;
54 };
55 
56 } // namespace details
57 
58 } // namespace yami
59 
60 #endif // YAMICPP_INCOMING_MESSAGE_QUEUE_H_INCLUDED
Namespace devoted to everything related to YAMI4.
Definition: activity_statistics_monitor.cpp:27