summaryrefslogtreecommitdiff
path: root/indra/newview/llmainlooprepeater.cpp
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-11-11 11:46:24 -0800
committerAndrew A. de Laix <alain@lindenlab.com>2010-11-11 11:46:24 -0800
commit7a7f89db6d9c5e6b2c6c89ea39c0302907a0442b (patch)
treef9f962b47c1e6c3fa32c40dec4e9e804e49614cb /indra/newview/llmainlooprepeater.cpp
parent4e22d63352dd65085cfbba9c22070271ecdd4bcf (diff)
fix termination issues with thread safe queue in main loop repeater service.
Diffstat (limited to 'indra/newview/llmainlooprepeater.cpp')
-rw-r--r--indra/newview/llmainlooprepeater.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/indra/newview/llmainlooprepeater.cpp b/indra/newview/llmainlooprepeater.cpp
index c2eba97641..ddc925a73b 100644
--- a/indra/newview/llmainlooprepeater.cpp
+++ b/indra/newview/llmainlooprepeater.cpp
@@ -36,7 +36,7 @@
LLMainLoopRepeater::LLMainLoopRepeater(void):
- mQueue(gAPRPoolp, 1024)
+ mQueue(0)
{
; // No op.
}
@@ -44,6 +44,9 @@ LLMainLoopRepeater::LLMainLoopRepeater(void):
void LLMainLoopRepeater::start(void)
{
+ if(mQueue != 0) return;
+
+ mQueue = new LLThreadSafeQueue<LLSD>(gAPRPoolp, 1024);
mMainLoopConnection = LLEventPumps::instance().
obtain("mainloop").listen("stupid name here", boost::bind(&LLMainLoopRepeater::onMainLoop, this, _1));
mRepeaterConnection = LLEventPumps::instance().
@@ -55,13 +58,16 @@ void LLMainLoopRepeater::stop(void)
{
mMainLoopConnection.release();
mRepeaterConnection.release();
+
+ delete mQueue;
+ mQueue = 0;
}
bool LLMainLoopRepeater::onMainLoop(LLSD const &)
{
LLSD message;
- while(mQueue.tryPopBack(message)) {
+ while(mQueue->tryPopBack(message)) {
std::string pump = message["pump"].asString();
if(pump.length() == 0 ) continue; // No pump.
LLEventPumps::instance().obtain(pump).post(message["payload"]);
@@ -73,7 +79,7 @@ bool LLMainLoopRepeater::onMainLoop(LLSD const &)
bool LLMainLoopRepeater::onMessage(LLSD const & event)
{
try {
- mQueue.pushFront(event);
+ mQueue->pushFront(event);
} catch(LLThreadSafeQueueError & e) {
llwarns << "could not repeat message (" << e.what() << ")" <<
event.asString() << LL_ENDL;