Ardour  9.0-pre0-582-g084a23a80d
PBD::CrossThreadPool Class Reference

#include <pool.h>

Inheritance diagram for PBD::CrossThreadPool:
[legend]

Public Member Functions

 CrossThreadPool (std::string n, unsigned long isize, unsigned long nitems, PerThreadPool *, PoolDumpCallback)
 
void * alloc ()
 
void push (void *)
 
PerThreadPoolparent () const
 
bool empty ()
 
guint pending_size () const
 
void flush_pending ()
 
void flush_pending_with_ev (void *)
 
- Public Member Functions inherited from PBD::Pool
 Pool (std::string name, unsigned long item_size, unsigned long nitems, PoolDumpCallback cb=NULL)
 
virtual ~Pool ()
 
virtual void release (void *)
 
std::string name () const
 
guint available () const
 
guint used () const
 
guint total () const
 

Private Attributes

PBD::RingBuffer< void * > pending
 
PerThreadPool_parent
 

Additional Inherited Members

- Protected Attributes inherited from PBD::Pool
PBD::RingBuffer< void * > free_list
 a list of pointers to free items within block More...
 
std::string _name
 

Detailed Description

Management of a per-thread pool of data that is allocated by one thread and freed by one other thread. Not safe for use when there is more than 1 reader and 1 writer.

This is basically a wrapper around a thread-local storage instance of a ringbuffer, made safe for use in the case where multiple threads allocate from the ringbuffer and a single thread "frees" the allocations.

Rather than using locks, each thread has its own ringbuffer (and associated data), and so it calls alloc(), passes a pointer to the result of the alloc to another thread, which later calls push() to "free" it.

Definition at line 118 of file pool.h.

Constructor & Destructor Documentation

◆ CrossThreadPool()

PBD::CrossThreadPool::CrossThreadPool ( std::string  n,
unsigned long  isize,
unsigned long  nitems,
PerThreadPool ,
PoolDumpCallback   
)

Member Function Documentation

◆ alloc()

void* PBD::CrossThreadPool::alloc ( )
virtual

Reimplemented from PBD::Pool.

◆ empty()

bool PBD::CrossThreadPool::empty ( )

◆ flush_pending()

void PBD::CrossThreadPool::flush_pending ( )

◆ flush_pending_with_ev()

void PBD::CrossThreadPool::flush_pending_with_ev ( void *  )

◆ parent()

PerThreadPool* PBD::CrossThreadPool::parent ( ) const
inline

Definition at line 126 of file pool.h.

◆ pending_size()

guint PBD::CrossThreadPool::pending_size ( ) const
inline

Definition at line 132 of file pool.h.

◆ push()

void PBD::CrossThreadPool::push ( void *  )

Member Data Documentation

◆ _parent

PerThreadPool* PBD::CrossThreadPool::_parent
private

Definition at line 142 of file pool.h.

◆ pending

PBD::RingBuffer<void*> PBD::CrossThreadPool::pending
private

Definition at line 141 of file pool.h.


The documentation for this class was generated from the following file: