@@ -48,7 +48,7 @@ class PtrQueue {
48
48
PtrQueueSet* const _qset;
49
49
50
50
// The (byte) index at which an object was last enqueued. Starts at
51
- // capacity_in_bytes (indicating an empty buffer) and goes towards zero.
51
+ // capacity (in bytes) (indicating an empty buffer) and goes towards zero.
52
52
// Value is always pointer-size aligned.
53
53
size_t _index;
54
54
@@ -91,49 +91,19 @@ class PtrQueue {
91
91
void ** buffer () const { return _buf; }
92
92
void set_buffer (void ** buffer) { _buf = buffer; }
93
93
94
- size_t index_in_bytes () const {
95
- return _index;
96
- }
97
-
98
- void set_index_in_bytes (size_t new_index) {
99
- assert (is_aligned (new_index, _element_size), " precondition" );
100
- assert (new_index <= capacity_in_bytes (), " precondition" );
101
- _index = new_index;
102
- }
103
-
104
94
size_t index () const {
105
- return byte_index_to_index (index_in_bytes () );
95
+ return byte_index_to_index (_index );
106
96
}
107
97
108
98
void set_index (size_t new_index) {
109
- set_index_in_bytes (index_to_byte_index (new_index));
99
+ assert (new_index <= capacity (), " precondition" );
100
+ _index = index_to_byte_index (new_index);
110
101
}
111
102
112
103
size_t capacity () const {
113
104
return byte_index_to_index (capacity_in_bytes ());
114
105
}
115
106
116
- // Forcibly set empty.
117
- void reset () {
118
- if (_buf != NULL ) {
119
- _index = capacity_in_bytes ();
120
- }
121
- }
122
-
123
- // Return the size of the in-use region.
124
- size_t size () const {
125
- size_t result = 0 ;
126
- if (_buf != NULL ) {
127
- assert (_index <= capacity_in_bytes (), " Invariant" );
128
- result = byte_index_to_index (capacity_in_bytes () - _index);
129
- }
130
- return result;
131
- }
132
-
133
- bool is_empty () const {
134
- return _buf == NULL || capacity_in_bytes () == _index;
135
- }
136
-
137
107
// To support compiler.
138
108
139
109
protected:
@@ -260,6 +230,9 @@ class PtrQueueSet {
260
230
PtrQueueSet (BufferNode::Allocator* allocator);
261
231
~PtrQueueSet ();
262
232
233
+ // Discard any buffered enqueued data.
234
+ void reset_queue (PtrQueue& queue);
235
+
263
236
// If queue has any buffered enqueued data, transfer it to this qset.
264
237
// Otherwise, deallocate queue's buffer.
265
238
void flush_queue (PtrQueue& queue);
0 commit comments