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 #ifndef MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_QUEUE_H_ |
| 6 #define MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_QUEUE_H_ |
| 7 |
| 8 #include <queue> |
| 9 |
| 10 #include "mojo/public/system/macros.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 class Message; |
| 15 |
| 16 class MessageQueue { |
| 17 public: |
| 18 MessageQueue(); |
| 19 ~MessageQueue(); |
| 20 |
| 21 bool IsEmpty() const; |
| 22 const Message* Peek() const; |
| 23 |
| 24 // This method transfers ownership of |message->data| and |message->handles| |
| 25 // to the message queue, resetting |message| in the process. |
| 26 void Push(Message* message); |
| 27 |
| 28 // Removes the next message from the queue, transferring ownership of its |
| 29 // data and handles to the given |message|. |
| 30 void Pop(Message* message); |
| 31 |
| 32 // Removes the next message from the queue, discarding its data and handles. |
| 33 // This is meant to be used in conjunction with |Peek|. |
| 34 void Pop(); |
| 35 |
| 36 private: |
| 37 std::queue<Message*> queue_; |
| 38 |
| 39 MOJO_DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
| 40 }; |
| 41 |
| 42 } // namespace mojo |
| 43 |
| 44 #endif // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_QUEUE_H_ |
OLD | NEW |