equal
deleted
inserted
replaced
52 PtrQueueSet* const _qset; |
52 PtrQueueSet* const _qset; |
53 |
53 |
54 // Whether updates should be logged. |
54 // Whether updates should be logged. |
55 bool _active; |
55 bool _active; |
56 |
56 |
57 // If true, the queue is permanent, and doesn't need to deallocate |
|
58 // its buffer in the destructor (since that obtains a lock which may not |
|
59 // be legally locked by then. |
|
60 const bool _permanent; |
|
61 |
|
62 // The (byte) index at which an object was last enqueued. Starts at |
57 // The (byte) index at which an object was last enqueued. Starts at |
63 // capacity_in_bytes (indicating an empty buffer) and goes towards zero. |
58 // capacity_in_bytes (indicating an empty buffer) and goes towards zero. |
64 // Value is always pointer-size aligned. |
59 // Value is always pointer-size aligned. |
65 size_t _index; |
60 size_t _index; |
66 |
61 |
109 |
104 |
110 size_t capacity() const { |
105 size_t capacity() const { |
111 return byte_index_to_index(capacity_in_bytes()); |
106 return byte_index_to_index(capacity_in_bytes()); |
112 } |
107 } |
113 |
108 |
114 // If there is a lock associated with this buffer, this is that lock. |
|
115 Mutex* _lock; |
|
116 |
|
117 PtrQueueSet* qset() { return _qset; } |
109 PtrQueueSet* qset() { return _qset; } |
118 bool is_permanent() const { return _permanent; } |
|
119 |
110 |
120 // Process queue entries and release resources. |
111 // Process queue entries and release resources. |
121 void flush_impl(); |
112 void flush_impl(); |
122 |
113 |
123 // Initialize this queue to contain a null buffer, and be part of the |
114 // Initialize this queue to contain a null buffer, and be part of the |
124 // given PtrQueueSet. |
115 // given PtrQueueSet. |
125 PtrQueue(PtrQueueSet* qset, bool permanent = false, bool active = false); |
116 PtrQueue(PtrQueueSet* qset, bool active = false); |
126 |
117 |
127 // Requires queue flushed or permanent. |
118 // Requires queue flushed. |
128 ~PtrQueue(); |
119 ~PtrQueue(); |
129 |
120 |
130 public: |
121 public: |
131 |
|
132 // Associate a lock with a ptr queue. |
|
133 void set_lock(Mutex* lock) { _lock = lock; } |
|
134 |
122 |
135 // Forcibly set empty. |
123 // Forcibly set empty. |
136 void reset() { |
124 void reset() { |
137 if (_buf != NULL) { |
125 if (_buf != NULL) { |
138 _index = capacity_in_bytes(); |
126 _index = capacity_in_bytes(); |