OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_PROCESS_QUEUE_H_ | 5 #ifndef SRC_VM_PROCESS_QUEUE_H_ |
6 #define SRC_VM_PROCESS_QUEUE_H_ | 6 #define SRC_VM_PROCESS_QUEUE_H_ |
7 | 7 |
8 #include "src/shared/assert.h" | 8 #include "src/shared/assert.h" |
9 #include "src/shared/atomic.h" | 9 #include "src/shared/atomic.h" |
10 | 10 |
11 #include "src/vm/process.h" | 11 #include "src/vm/process.h" |
12 | 12 |
13 namespace fletch { | 13 namespace dartino { |
14 | 14 |
15 class ThreadState; | 15 class ThreadState; |
16 | 16 |
17 class ProcessQueue { | 17 class ProcessQueue { |
18 public: | 18 public: |
19 ProcessQueue() : head_(NULL), tail_(NULL) {} | 19 ProcessQueue() : head_(NULL), tail_(NULL) {} |
20 | 20 |
21 // Try to enqueue [entry]. | 21 // Try to enqueue [entry]. |
22 // Returns false if it was not possible to modify the queue. The operation | 22 // Returns false if it was not possible to modify the queue. The operation |
23 // should be repeated. | 23 // should be repeated. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 private: | 141 private: |
142 Process* const kSentinel = reinterpret_cast<Process*>(1); | 142 Process* const kSentinel = reinterpret_cast<Process*>(1); |
143 | 143 |
144 Atomic<Process*> head_; | 144 Atomic<Process*> head_; |
145 // The tail_ field is only modified under a lock on head_. This gives us the | 145 // The tail_ field is only modified under a lock on head_. This gives us the |
146 // right memory-order on tail_, without read/writes being explicit atomic. | 146 // right memory-order on tail_, without read/writes being explicit atomic. |
147 Process* tail_; | 147 Process* tail_; |
148 }; | 148 }; |
149 | 149 |
150 } // namespace fletch | 150 } // namespace dartino |
151 | 151 |
152 #endif // SRC_VM_PROCESS_QUEUE_H_ | 152 #endif // SRC_VM_PROCESS_QUEUE_H_ |
OLD | NEW |