| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CIRCULAR_QUEUE_H_ | 5 #ifndef V8_CIRCULAR_QUEUE_H_ |
| 6 #define V8_CIRCULAR_QUEUE_H_ | 6 #define V8_CIRCULAR_QUEUE_H_ |
| 7 | 7 |
| 8 #include "src/atomicops.h" | 8 #include "src/base/atomicops.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 | 14 |
| 15 // Lock-free cache-friendly sampling circular queue for large | 15 // Lock-free cache-friendly sampling circular queue for large |
| 16 // records. Intended for fast transfer of large records between a | 16 // records. Intended for fast transfer of large records between a |
| 17 // single producer and a single consumer. If the queue is full, | 17 // single producer and a single consumer. If the queue is full, |
| 18 // StartEnqueue will return NULL. The queue is designed with | 18 // StartEnqueue will return NULL. The queue is designed with |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 // Reserved values for the entry marker. | 43 // Reserved values for the entry marker. |
| 44 enum { | 44 enum { |
| 45 kEmpty, // Marks clean (processed) entries. | 45 kEmpty, // Marks clean (processed) entries. |
| 46 kFull // Marks entries already filled by the producer but not yet | 46 kFull // Marks entries already filled by the producer but not yet |
| 47 // completely processed by the consumer. | 47 // completely processed by the consumer. |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 struct V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry { | 50 struct V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry { |
| 51 Entry() : marker(kEmpty) {} | 51 Entry() : marker(kEmpty) {} |
| 52 T record; | 52 T record; |
| 53 Atomic32 marker; | 53 base::Atomic32 marker; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 Entry* Next(Entry* entry); | 56 Entry* Next(Entry* entry); |
| 57 | 57 |
| 58 Entry buffer_[Length]; | 58 Entry buffer_[Length]; |
| 59 V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry* enqueue_pos_; | 59 V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry* enqueue_pos_; |
| 60 V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry* dequeue_pos_; | 60 V8_ALIGNED(PROCESSOR_CACHE_LINE_SIZE) Entry* dequeue_pos_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); | 62 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 | 65 |
| 66 } } // namespace v8::internal | 66 } } // namespace v8::internal |
| 67 | 67 |
| 68 #endif // V8_CIRCULAR_QUEUE_H_ | 68 #endif // V8_CIRCULAR_QUEUE_H_ |
| OLD | NEW |