11 #include <semaphore.h> 45 maxNumOfBuffers (_maxNumOfBuffers),
58 while (buffer.size () > 0)
60 RasterPtr r = buffer.front ();
76 if (buffer.size () > 0)
78 RasterPtr r = buffer.front ();
80 memoryConsumed = memoryConsumed - r->MemoryConsumedEstimated ();
95 return maxNumOfBuffers - (kkint32)buffer.size ();
101 return (kkint32)buffer.size ();
110 errMsg <<
"RasterBuffer::AddRaster raster == NULL";
111 cerr << std::endl << std::endl << errMsg << std::endl << std::endl;
117 while (buffer.size () >= (kkuint32)maxNumOfBuffers)
118 ThrowOutOldestOccupiedBuffer ();
120 buffer.push (raster);
130 RasterPtr result = NULL;
134 if (buffer.size () > 0)
136 result = buffer.front ();
138 memoryConsumed = memoryConsumed - result->MemoryConsumedEstimated ();
151 result = memoryConsumed;
160 RasterPtr result = NULL;
162 if (buffer.size () > 0)
164 result =
new Raster (*(buffer.back ()));
RasterPtr GetCopyOfLastImage()
Returns a copy of the last Raster instance added to the queue; if buffer is empty will return NULL...
static void Destroy(volatile GoalKeeperPtr &_goalKeeperInstance)
Destroys an existing instance of GoalKeeper.
kkint32 MemoryConsumedEstimated()
Returns an estimate of the amount of memory consumed in bytes.
kkint32 MemoryConsumedEstimated() const
static void Create(const KKStr &_name, volatile GoalKeeperPtr &_newGoalKeeper)
Create a GoalKeeper object and avoid a race condition doing it.
RasterBuffer(const KKStr &_name, kkint32 _maxNumOfBuffers)
Constructor.
KKStr operator+(const char *left, const KKStr &right)
KKStr(const KKStr &str)
Copy Constructor.
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
kkint32 NumAvailable() const
The number of entries that are left in the buffer before 'maxNumOfBuffers' is reached.
RasterPtr GetNextRaster()
Removes from the buffer the oldest instance of 'Raster' and returns it to caller; if buffer is empty ...
Will manage a buffer that will allow multiple threads to add and remove instances of 'Raster' objects...
kkint32 MemoryConsumedEstimated() const
kkint32 NumPopulated() const
KKException(const KKStr &_exceptionStr)
void AddRaster(RasterPtr raster)
Adds 'raster' to the end of the queue giving the queue ownership of the instance. ...