Mir
reordering_message_sender.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  */
18 
19 #ifndef MIR_FRONTEND_REORDERING_MESSAGE_SENDER_H_
20 #define MIR_FRONTEND_REORDERING_MESSAGE_SENDER_H_
21 
22 #include "message_sender.h"
23 
24 #include <mutex>
25 
26 namespace mir
27 {
28 namespace frontend
29 {
30 
36 {
37 public:
38  explicit ReorderingMessageSender(std::shared_ptr<MessageSender> const& sink);
39 
40  void send(char const* data, size_t length, FdSets const& fds) override;
41 
48  void uncork();
49 private:
50  struct Message
51  {
52  std::vector<char> data;
53  FdSets fds;
54  };
55  std::mutex message_lock;
56  bool corked;
57  std::vector<Message> buffered_messages;
58  std::shared_ptr<MessageSender> const sink;
59 };
60 
61 }
62 }
63 
64 #endif //MIR_FRONTEND_REORDERING_MESSAGE_SENDER_H_
A MessageSender that buffers all messages until triggered, then forwards all messages to an underlyin...
Definition: reordering_message_sender.h:35
Definition: message_sender.h:29
All things Mir.
Definition: atomic_callback.h:25
void uncork()
Stop diverting messages into the buffer.
Definition: reordering_message_sender.cpp:46
void send(char const *data, size_t length, FdSets const &fds) override
Definition: reordering_message_sender.cpp:29
ReorderingMessageSender(std::shared_ptr< MessageSender > const &sink)
Definition: reordering_message_sender.cpp:23
std::vector< std::vector< Fd > > FdSets
Definition: fd_sets.h:29

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016