OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "mojo/public/bindings/lib/message_queue.h" | |
6 | |
7 #include <assert.h> | |
8 #include <stddef.h> | |
9 | |
10 #include "mojo/public/cpp/bindings/message.h" | |
11 | |
12 namespace mojo { | |
13 namespace internal { | |
14 | |
15 MessageQueue::MessageQueue() { | |
16 } | |
17 | |
18 MessageQueue::~MessageQueue() { | |
19 while (!queue_.empty()) | |
20 Pop(); | |
21 } | |
22 | |
23 bool MessageQueue::IsEmpty() const { | |
24 return queue_.empty(); | |
25 } | |
26 | |
27 Message* MessageQueue::Peek() { | |
28 assert(!queue_.empty()); | |
29 return queue_.front(); | |
30 } | |
31 | |
32 void MessageQueue::Push(Message* message) { | |
33 queue_.push(new Message()); | |
34 queue_.back()->Swap(message); | |
35 } | |
36 | |
37 void MessageQueue::Pop(Message* message) { | |
38 assert(!queue_.empty()); | |
39 queue_.front()->Swap(message); | |
40 Pop(); | |
41 } | |
42 | |
43 void MessageQueue::Pop() { | |
44 assert(!queue_.empty()); | |
45 delete queue_.front(); | |
46 queue_.pop(); | |
47 } | |
48 | |
49 } // namespace internal | |
50 } // namespace mojo | |
OLD | NEW |