OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #ifndef SRC_VM_MAILBOX_H_ | 5 #ifndef SRC_VM_MAILBOX_H_ |
6 #define SRC_VM_MAILBOX_H_ | 6 #define SRC_VM_MAILBOX_H_ |
7 | 7 |
8 #include "src/shared/globals.h" | 8 #include "src/shared/globals.h" |
9 #include "src/shared/atomic.h" | 9 #include "src/shared/atomic.h" |
10 | 10 |
11 #include "src/vm/object.h" | 11 #include "src/vm/object.h" |
12 | 12 |
13 namespace fletch { | 13 namespace dartino { |
14 | 14 |
15 template <typename MessageType> | 15 template <typename MessageType> |
16 class Mailbox { | 16 class Mailbox { |
17 public: | 17 public: |
18 Mailbox() : last_message_(NULL), current_message_(NULL) {} | 18 Mailbox() : last_message_(NULL), current_message_(NULL) {} |
19 ~Mailbox() { | 19 ~Mailbox() { |
20 while (last_message_.load() != NULL) { | 20 while (last_message_.load() != NULL) { |
21 MessageType* entry = last_message_; | 21 MessageType* entry = last_message_; |
22 last_message_ = entry->next(); | 22 last_message_ = entry->next(); |
23 delete entry; | 23 delete entry; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 public: | 100 public: |
101 MailboxMessage() : next_(NULL) {} | 101 MailboxMessage() : next_(NULL) {} |
102 | 102 |
103 MessageType* next() const { return next_; } | 103 MessageType* next() const { return next_; } |
104 void set_next(MessageType* next) { next_ = next; } | 104 void set_next(MessageType* next) { next_ = next; } |
105 | 105 |
106 private: | 106 private: |
107 MessageType* next_; | 107 MessageType* next_; |
108 }; | 108 }; |
109 | 109 |
110 } // namespace fletch | 110 } // namespace dartino |
111 | 111 |
112 #endif // SRC_VM_MAILBOX_H_ | 112 #endif // SRC_VM_MAILBOX_H_ |
OLD | NEW |