![]() |
KSquare Utilities
|
Will manage a buffer that will allow multiple threads to add and remove messages to a queue. More...
#include <MsgQueue.h>
Public Types | |
| typedef MsgQueue * | MsgQueuePtr |
Public Member Functions | |
| MsgQueue (const KKStr &_name) | |
| ~MsgQueue () | |
| void | AddMsg (KKStrPtr msg) |
| Take ownership of 'msg' and add to end of the queue. More... | |
| 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 that its owns (taking ownership) the KKStr instances or create duplicates. More... | |
| KKStrListPtr | GetAllMsgs () |
| Returns all messages that are currently in the queue. More... | |
| KKStrPtr | GetCopyOfLastMsg () |
| Returns a duplicate of the last string added to the message queue. More... | |
| KKStrPtr | GetNextMsg () |
| Removes from the queue the oldest message added to the queue that has not been removed. More... | |
| kkint32 | MemoryConsumedEstimated () |
| Returns an estimate of the amount of memory consumed in bytes by this instance. More... | |
Will manage a buffer that will allow multiple threads to add and remove messages to a queue.
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 Queue.
Definition at line 19 of file MsgQueue.h.
| typedef MsgQueue* KKB::MsgQueue::MsgQueuePtr |
Definition at line 22 of file MsgQueue.h.
| MsgQueue::MsgQueue | ( | const KKStr & | _name | ) |
Definition at line 29 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::Create(), KKB::KKStr::KKStr(), KKB::GoalKeeperSimple::MemoryConsumedEstimated(), MsgQueue(), and KKB::operator+().
Referenced by MsgQueue().
| MsgQueue::~MsgQueue | ( | ) |
Definition at line 41 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::Destroy().
| void MsgQueue::AddMsg | ( | KKStrPtr | msg | ) |
Take ownership of 'msg' and add to end of the queue.
| [in] | msg | Pointer to message that is to be added to end of queue. The caller will pass ownership of this string to this instance of MsgQueue.Taking ownership of 'msg' |
Definition at line 58 of file MsgQueue.cpp.
References KKB::KKStr::Concat(), KKB::GoalKeeperSimple::EndBlock(), KKB::KKException::KKException(), KKB::KKStr::MemoryConsumedEstimated(), and KKB::GoalKeeperSimple::StartBlock().
Referenced by KKB::KKThread::AddMsg().
| void MsgQueue::AddMsg | ( | const KKStr & | msg | ) |
Definition at line 76 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), KKB::KKStr::MemoryConsumedEstimated(), and KKB::GoalKeeperSimple::StartBlock().
Referenced by KKB::KKThread::AddMsg(), and KKB::RunLog::WriteLine().
| void MsgQueue::AddMsgs | ( | const KKStrListPtr | msgs, |
| bool | takeOwnership | ||
| ) |
Adds the contents of 'msgs' to the message queue and depending on 'takeOwnership' will either assume that its owns (taking ownership) the KKStr instances or create duplicates.
If 'takeOwnership' is true will and the KKStr instances in 'msgs' to the queue otherwise it will make duplicates of the KKStr instances. It is up to the caller to make sure that they set the Owner flag on the 'msgs' instance; for example if 'takeOwnership' is 'true' then caller should set 'msgs.Owner (false);'.
Definition at line 86 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), KKB::KKStr::MemoryConsumedEstimated(), and KKB::GoalKeeperSimple::StartBlock().
| KKStrListPtr MsgQueue::GetAllMsgs | ( | ) |
Returns all messages that are currently in the queue.
Definition at line 125 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), KKB::KKStrList::KKStrList(), and KKB::GoalKeeperSimple::StartBlock().
| KKStrPtr MsgQueue::GetCopyOfLastMsg | ( | ) |
Returns a duplicate of the last string added to the message queue.
This will not effect the current copy of the message queue. The returned string will be owned by the caller who will be responsible for deleting it.
Definition at line 157 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), and KKB::GoalKeeperSimple::StartBlock().
| KKStrPtr MsgQueue::GetNextMsg | ( | ) |
Removes from the queue the oldest message added to the queue that has not been removed.
The caller will get ownership of the string and be responsible for deleting it.
Definition at line 107 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), and KKB::GoalKeeperSimple::StartBlock().
Referenced by KKB::KKThread::GetMsgs().
| kkint32 MsgQueue::MemoryConsumedEstimated | ( | ) |
Returns an estimate of the amount of memory consumed in bytes by this instance.
This will help managed objects keep track of how much memory they are using in the unmanaged world.
Definition at line 146 of file MsgQueue.cpp.
References KKB::GoalKeeperSimple::EndBlock(), and KKB::GoalKeeperSimple::StartBlock().
Referenced by KKB::KKThread::MemoryConsumedEstimated().