OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 29 matching lines...) Expand all Loading... |
40 // simultaneous reads and writes to adjanced memory locations. | 40 // simultaneous reads and writes to adjanced memory locations. |
41 // | 41 // |
42 // IMPORTANT: as a producer never checks for chunks cleanness, it is | 42 // IMPORTANT: as a producer never checks for chunks cleanness, it is |
43 // possible that it can catch up and overwrite a chunk that a consumer | 43 // possible that it can catch up and overwrite a chunk that a consumer |
44 // is currently reading, resulting in a corrupt record being read. | 44 // is currently reading, resulting in a corrupt record being read. |
45 class SamplingCircularQueue { | 45 class SamplingCircularQueue { |
46 public: | 46 public: |
47 // Executed on the application thread. | 47 // Executed on the application thread. |
48 SamplingCircularQueue(int record_size_in_bytes, | 48 SamplingCircularQueue(int record_size_in_bytes, |
49 int desired_chunk_size_in_bytes, | 49 int desired_chunk_size_in_bytes, |
50 int buffer_size_in_chunks, | 50 int buffer_size_in_chunks); |
51 bool keep_producer_consumer_distance = true); | |
52 ~SamplingCircularQueue(); | 51 ~SamplingCircularQueue(); |
53 | 52 |
54 // Enqueue returns a pointer to a memory location for storing the next | 53 // Enqueue returns a pointer to a memory location for storing the next |
55 // record. | 54 // record. |
56 INLINE(void* Enqueue()); | 55 INLINE(void* Enqueue()); |
57 | 56 |
58 // Executed on the consumer (analyzer) thread. | 57 // Executed on the consumer (analyzer) thread. |
59 // StartDequeue returns a pointer to a memory location for retrieving | 58 // StartDequeue returns a pointer to a memory location for retrieving |
60 // the next record. After the record had been read by a consumer, | 59 // the next record. After the record had been read by a consumer, |
61 // FinishDequeue must be called. Until that moment, subsequent calls | 60 // FinishDequeue must be called. Until that moment, subsequent calls |
(...skipping 20 matching lines...) Expand all Loading... |
82 Cell* dequeue_pos; | 81 Cell* dequeue_pos; |
83 Cell* dequeue_end_pos; | 82 Cell* dequeue_end_pos; |
84 }; | 83 }; |
85 | 84 |
86 INLINE(void WrapPositionIfNeeded(Cell** pos)); | 85 INLINE(void WrapPositionIfNeeded(Cell** pos)); |
87 | 86 |
88 const int record_size_; | 87 const int record_size_; |
89 const int chunk_size_in_bytes_; | 88 const int chunk_size_in_bytes_; |
90 const int chunk_size_; | 89 const int chunk_size_; |
91 const int buffer_size_; | 90 const int buffer_size_; |
| 91 const int producer_consumer_distance_; |
92 Cell* buffer_; | 92 Cell* buffer_; |
93 byte* positions_; | 93 byte* positions_; |
94 ProducerPosition* producer_pos_; | 94 ProducerPosition* producer_pos_; |
95 ConsumerPosition* consumer_pos_; | 95 ConsumerPosition* consumer_pos_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); | 97 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); |
98 }; | 98 }; |
99 | 99 |
100 | 100 |
101 } } // namespace v8::internal | 101 } } // namespace v8::internal |
102 | 102 |
103 #endif // V8_CIRCULAR_QUEUE_H_ | 103 #endif // V8_CIRCULAR_QUEUE_H_ |
OLD | NEW |