diff options
author | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-11-09 15:59:29 +0200 |
---|---|---|
committer | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-11-09 15:59:29 +0200 |
commit | 1b0732183e4437ce673b13c8092f8122db884587 (patch) | |
tree | dc913dbaab1699bb27854d9f22531aa2a6f86e28 /indra/llcommon/llqueuedthread.cpp | |
parent | 148a29ea1ec97922180ca8f0f6ced9a4a9e05c07 (diff) | |
parent | 21c51025da7f9128a1b425a5e88331ae0e3fe4d4 (diff) |
Merge
--HG--
branch : product-engine
Diffstat (limited to 'indra/llcommon/llqueuedthread.cpp')
-rw-r--r-- | indra/llcommon/llqueuedthread.cpp | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 3db5c36545..e7ad571a90 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -42,7 +42,8 @@ LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded) : LLThread(name), mThreaded(threaded), mIdleThread(TRUE), - mNextHandle(0) + mNextHandle(0), + mStarted(FALSE) { if (mThreaded) { @@ -53,6 +54,10 @@ LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded) : // MAIN THREAD LLQueuedThread::~LLQueuedThread() { + if (!mThreaded) + { + endThread(); + } shutdown(); // ~LLThread() will be called here } @@ -106,6 +111,14 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(U32 max_time_ms) { + if (!mStarted) + { + if (!mThreaded) + { + startThread(); + mStarted = TRUE; + } + } return updateQueue(max_time_ms); } @@ -452,26 +465,12 @@ S32 LLQueuedThread::processNextRequest() } } - S32 res; S32 pending = getPending(); - if (pending == 0) - { - if (isQuitting()) - { - res = -1; // exit thread - } - else - { - res = 0; - } - } - else - { - res = pending; - } - return res; + + return pending; } +// virtual bool LLQueuedThread::runCondition() { // mRunCondition must be locked here @@ -481,35 +480,53 @@ bool LLQueuedThread::runCondition() return true; } +// virtual void LLQueuedThread::run() { + // call checPause() immediately so we don't try to do anything before the class is fully constructed + checkPause(); + startThread(); + mStarted = TRUE; + while (1) { // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. checkPause(); - if(isQuitting()) + if (isQuitting()) + { + endThread(); break; - - //llinfos << "QUEUED THREAD RUNNING, queue size = " << mRequestQueue.size() << llendl; + } mIdleThread = FALSE; + + threadedUpdate(); int res = processNextRequest(); if (res == 0) { mIdleThread = TRUE; + ms_sleep(1); } - - if (res < 0) // finished working and want to exit - { - break; - } - //LLThread::yield(); // thread should yield after each request } + llinfos << "LLQueuedThread " << mName << " EXITING." << llendl; +} + +// virtual +void LLQueuedThread::startThread() +{ +} - llinfos << "QUEUED THREAD " << mName << " EXITING." << llendl; +// virtual +void LLQueuedThread::endThread() +{ +} + +// virtual +void LLQueuedThread::threadedUpdate() +{ } //============================================================================ |