libsdr
0.1.0
A simple SDR library
|
A set of buffers, that tracks their usage. More...
#include <buffer.hh>
Public Member Functions | |
BufferSet (size_t N, size_t size) | |
Preallocates N buffers of size size . More... | |
virtual | ~BufferSet () |
Destructor, unreferences all buffers. More... | |
bool | hasBuffer () |
Returns true if there is a free buffer. More... | |
Buffer< Scalar > | getBuffer () |
Obtains a free buffer. More... | |
virtual void | bufferUnused (const RawBuffer &buffer) |
Callback gets called once the buffer gets unused. More... | |
void | resize (size_t numBuffers) |
Resize the buffer set. More... | |
Protected Attributes | |
size_t | _bufferSize |
Size of each buffer. More... | |
std::map< void *, Buffer< Scalar > > | _buffers |
Holds a reference to each buffer of the buffer set, referenced by the data pointer of the buffer. More... | |
std::vector< void * > | _free_buffers |
A vector of all unused buffers. More... | |
A set of buffers, that tracks their usage.
Frequently it is impossible to predict the time, a buffer will be in use. Instead of allocating a new buffer during runtime, one may allocate several buffer in advance. In this case, it is important to track which buffer is still in use efficiently. This class implements this functionality. A BufferSet
pre-allocates several buffers. Once a buffer is requested from the set, it gets marked as "in-use". Once the buffer gets ununsed, it will be marked as "unused" and will be available again.
|
inline |
Preallocates N buffers of size size
.
|
inlinevirtual |
Destructor, unreferences all buffers.
Buffers still in use, are freed once they are dereferenced.
|
inlinevirtual |
Callback gets called once the buffer gets unused.
Implements sdr::BufferOwner.
|
inline |
Obtains a free buffer.
|
inline |
Returns true if there is a free buffer.
|
inline |
Resize the buffer set.
|
protected |
Holds a reference to each buffer of the buffer set, referenced by the data pointer of the buffer.
|
protected |
Size of each buffer.
|
protected |
A vector of all unused buffers.