286 // Deallocate some of the available buffers. remove_goal is the target
287 // number to remove. Returns the number actually deallocated, which may
288 // be less than the goal if there were fewer available.
289 size_t reduce_free_list(size_t remove_goal);
290 };
291
292 // A PtrQueueSet represents resources common to a set of pointer queues.
293 // In particular, the individual queues allocate buffers from this shared
294 // set, and return completed buffers to the set.
295 class PtrQueueSet {
296 BufferNode::Allocator* _allocator;
297
298 // Noncopyable - not defined.
299 PtrQueueSet(const PtrQueueSet&);
300 PtrQueueSet& operator=(const PtrQueueSet&);
301
302 protected:
303 bool _all_active;
304
305 // Create an empty ptr queue set.
306 PtrQueueSet();
307 ~PtrQueueSet();
308
309 // Because of init-order concerns, we can't pass these as constructor
310 // arguments.
311 void initialize(BufferNode::Allocator* allocator);
312
313 public:
314
315 // Return the associated BufferNode allocator.
316 BufferNode::Allocator* allocator() const { return _allocator; }
317
318 // Return the buffer for a BufferNode of size buffer_size().
319 void** allocate_buffer();
320
321 // Return an empty buffer to the free list. The node is required
322 // to have been allocated with a size of buffer_size().
323 void deallocate_buffer(BufferNode* node);
324
325 // A completed buffer is a buffer the mutator is finished with, and
326 // is ready to be processed by the collector. It need not be full.
327
328 // Adds node to the completed buffer list.
329 virtual void enqueue_completed_buffer(BufferNode* node) = 0;
330
331 bool is_active() { return _all_active; }
|
286 // Deallocate some of the available buffers. remove_goal is the target
287 // number to remove. Returns the number actually deallocated, which may
288 // be less than the goal if there were fewer available.
289 size_t reduce_free_list(size_t remove_goal);
290 };
291
292 // A PtrQueueSet represents resources common to a set of pointer queues.
293 // In particular, the individual queues allocate buffers from this shared
294 // set, and return completed buffers to the set.
295 class PtrQueueSet {
296 BufferNode::Allocator* _allocator;
297
298 // Noncopyable - not defined.
299 PtrQueueSet(const PtrQueueSet&);
300 PtrQueueSet& operator=(const PtrQueueSet&);
301
302 protected:
303 bool _all_active;
304
305 // Create an empty ptr queue set.
306 PtrQueueSet(BufferNode::Allocator* allocator);
307 ~PtrQueueSet();
308
309 public:
310
311 // Return the associated BufferNode allocator.
312 BufferNode::Allocator* allocator() const { return _allocator; }
313
314 // Return the buffer for a BufferNode of size buffer_size().
315 void** allocate_buffer();
316
317 // Return an empty buffer to the free list. The node is required
318 // to have been allocated with a size of buffer_size().
319 void deallocate_buffer(BufferNode* node);
320
321 // A completed buffer is a buffer the mutator is finished with, and
322 // is ready to be processed by the collector. It need not be full.
323
324 // Adds node to the completed buffer list.
325 virtual void enqueue_completed_buffer(BufferNode* node) = 0;
326
327 bool is_active() { return _all_active; }
|