![]() |
KSquare Utilities
|
Will manage a buffer that will allow multiple threads to add and remove instances of 'Raster' objects. More...
#include <RasterBuffer.h>
Public Types | |
| typedef RasterBuffer * | RasterBufferPtr |
Public Member Functions | |
| RasterBuffer (const KKStr &_name, kkint32 _maxNumOfBuffers) | |
| Constructor. More... | |
| ~RasterBuffer () | |
| void | AddRaster (RasterPtr raster) |
| Adds 'raster' to the end of the queue giving the queue ownership of the instance. More... | |
| RasterPtr | GetCopyOfLastImage () |
| Returns a copy of the last Raster instance added to the queue; if buffer is empty will return NULL. More... | |
| RasterPtr | GetNextRaster () |
| Removes from the buffer the oldest instance of 'Raster' and returns it to caller; if buffer is empty will return NULL. More... | |
| kkint32 | MaxNumOfBuffers () const |
| void | MaxNumOfBuffers (kkint32 _maxNumOfBuffers) |
| kkint32 | MemoryConsumedEstimated () |
| Returns an estimate of the amount of memory consumed in bytes. More... | |
| kkint32 | NumAvailable () const |
| The number of entries that are left in the buffer before 'maxNumOfBuffers' is reached. More... | |
| kkint32 | NumPopulated () const |
| kkint32 | RastersDropped () const |
| Returns the number of 'Raster' instances that had to be deleted because the size of the queue had reached 'maxNumOfBuffers'. More... | |
Will manage a buffer that will allow multiple threads to add and remove instances of 'Raster' objects.
A 'GoalKeepeer' object 'gateKeeper' will be used to enforce integrity in the Multi-Threaded environment. It will guarantee that only one thread at a time can access the Raster Queue. This queue will take ownership of 'Raster' instances added to it via 'AddRaster'. It will pass ownership of the 'Raster' instances when it returns them in GetNextRaster. When a 'RasterBuffer' instance is deleted it will delete all the 'Raster' instances it still contains.
Definition at line 34 of file RasterBuffer.h.
Definition at line 37 of file RasterBuffer.h.
Constructor.
| [in] | _name | Name of the buffer; this will be used by the associated 'GateKeeper' instance; should be unique. |
| [in] | _maxNumOfBuffers | The maximum number of raster instances that can be added to this buffer. When this limit has been reached the oldest entries in the list will be deleted when a new one is added (AddRaster). |
Definition at line 39 of file RasterBuffer.cpp.
References KKB::GoalKeeper::Create(), KKB::KKStr::KKStr(), KKB::GoalKeeper::MemoryConsumedEstimated(), KKB::operator+(), and RasterBuffer().
Referenced by RasterBuffer().
| RasterBuffer::~RasterBuffer | ( | ) |
Definition at line 56 of file RasterBuffer.cpp.
References KKB::GoalKeeper::Destroy().
| void RasterBuffer::AddRaster | ( | RasterPtr | raster | ) |
Adds 'raster' to the end of the queue giving the queue ownership of the instance.
If the number of entries in the queue are already equal or greater than 'MaxNumOfBuffers' specified then the oldest instances in the queue(back of the queue) will be removed and deleted until the size of the queue is less than 'MaxNumOfBuffers' before adding this new instance.
Definition at line 105 of file RasterBuffer.cpp.
References KKB::KKStr::Concat(), KKB::GoalKeeper::EndBlock(), KKB::KKException::KKException(), KKB::Raster::MemoryConsumedEstimated(), and KKB::GoalKeeper::StartBlock().
| RasterPtr RasterBuffer::GetCopyOfLastImage | ( | ) |
Returns a copy of the last Raster instance added to the queue; if buffer is empty will return NULL.
Caller will get ownership and be responsible for deleting it.
Definition at line 158 of file RasterBuffer.cpp.
References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().
| RasterPtr RasterBuffer::GetNextRaster | ( | ) |
Removes from the buffer the oldest instance of 'Raster' and returns it to caller; if buffer is empty will return NULL.
Definition at line 128 of file RasterBuffer.cpp.
References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().
|
inline |
Definition at line 55 of file RasterBuffer.h.
|
inline |
Definition at line 69 of file RasterBuffer.h.
| kkint32 RasterBuffer::MemoryConsumedEstimated | ( | ) |
Returns an estimate of the amount of memory consumed in bytes.
This will help managed objects keep track of how much memory they are using in the unmanaged world.
Definition at line 147 of file RasterBuffer.cpp.
References KKB::GoalKeeper::EndBlock(), and KKB::GoalKeeper::StartBlock().
| kkint32 RasterBuffer::NumAvailable | ( | ) | const |
The number of entries that are left in the buffer before 'maxNumOfBuffers' is reached.
Definition at line 93 of file RasterBuffer.cpp.
| kkint32 RasterBuffer::NumPopulated | ( | ) | const |
Definition at line 99 of file RasterBuffer.cpp.
|
inline |
Returns the number of 'Raster' instances that had to be deleted because the size of the queue had reached 'maxNumOfBuffers'.
Definition at line 53 of file RasterBuffer.h.