11 #include <semaphore.h> 43 while (
this->queue.size () > 0)
45 KKStrPtr m =
this->queue.front ();
63 errMsg <<
"MsgQueue::AddMsg == NULL";
64 cerr << std::endl << std::endl << errMsg << std::endl << std::endl;
79 queue.push (
new KKStr (msg));
91 KKStrList::iterator idx;
92 for (idx = msgs->begin (); idx != msgs->end (); ++idx)
98 queue.push (
new KKStr (*msg));
112 if (queue.size () > 0)
114 msg = queue.front ();
116 memoryConsumed = memoryConsumed - msg->MemoryConsumedEstimated ();
131 while (queue.size () > 0)
133 msg = queue.front ();
135 result->PushOnBack (msg);
136 memoryConsumed = memoryConsumed - msg->MemoryConsumedEstimated ();
150 result = memoryConsumed;
161 if (queue.size () > 0)
163 msg =
new KKStr (*(queue.back ()));
void AddMsg(KKStrPtr msg)
Take ownership of 'msg' and add to end of the queue.
kkint32 MemoryConsumedEstimated() const
kkint32 MemoryConsumedEstimated()
Returns an estimate of the amount of memory consumed in bytes by this instance.
void AddMsg(const KKStr &msg)
void AddMsgs(const KKStrListPtr msgs, bool takeOwnership)
Adds the contents of 'msgs' to the message queue and depending on 'takeOwnership' will either assume ...
static void Destroy(volatile GoalKeeperSimplePtr &_goalKeeperInstance)
Destroys an existing instance of GoalKeeperSimple.
A simple/ light-weight implementation of critical section blocking.
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
KKStrPtr GetNextMsg()
Removes from the queue the oldest message added to the queue that has not been removed.
KKStrListPtr GetAllMsgs()
Returns all messages that are currently in the queue.
KKStr operator+(const char *left, const KKStr &right)
KKStr(const KKStr &str)
Copy Constructor.
Will manage a buffer that will allow multiple threads to add and remove messages to a queue...
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
MsgQueue(const KKStr &_name)
static void Create(const KKStr &_name, volatile GoalKeeperSimplePtr &_newGoalKeeper)
Create a GoalKeeperSimple object and avoid a race condition doing it.
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
KKStrPtr GetCopyOfLastMsg()
Returns a duplicate of the last string added to the message queue.
KKException(const KKStr &_exceptionStr)
kkint32 MemoryConsumedEstimated() const