Thread safe memory pool for reusing Waveform objects.
More...
#include <WaveformPool.h>
|
size_t | m_maxSize |
| Maximum number of waveforms to store in the pool.
|
|
std::mutex | m_mutex |
| Mutex for synchronizing access to m_waveforms across threads.
|
|
std::list< WaveformBase * > | m_waveforms |
| The list of free waveforms.
|
|
Thread safe memory pool for reusing Waveform objects.
Allocating and freeing GPU memory can be an expensive operation so it's usually preferable to recycle existing Waveform objects if possible.
◆ WaveformPool()
WaveformPool::WaveformPool |
( |
size_t |
maxSize = 16 | ) |
|
|
inline |
Creates a waveform pool.
- Parameters
-
maxSize | Maximum number of waveforms to store in the pool |
◆ Add()
Adds a new waveform to the pool if there's sufficient free slots in the pool.
If the pool is already full the waveform is destroyed.
- Parameters
-
◆ clear()
bool WaveformPool::clear |
( |
| ) |
|
|
inline |
Free all waveforms in the pool to reclaim memory.
- Returns
- True if memory was freed, false if pool was empty to begin with
◆ Get()
Attempts to get a waveform from the pool.
- Returns
- The waveform, if one is available. Returns nullptr if the pool is empty.
The documentation for this class was generated from the following file: