diff options
author | Jacek Antonelli | 2010-02-08 17:25:48 -0600 |
---|---|---|
committer | Jacek Antonelli | 2010-02-08 17:25:48 -0600 |
commit | 02dee1652be7868d588fefa8b8e672be40088bdb (patch) | |
tree | cafeaf4d499b53b745ba1b3c92c10c05f7382925 /linden/indra/llcommon | |
parent | Ported many APR changes from Snowglobe. (diff) | |
download | meta-impy-02dee1652be7868d588fefa8b8e672be40088bdb.zip meta-impy-02dee1652be7868d588fefa8b8e672be40088bdb.tar.gz meta-impy-02dee1652be7868d588fefa8b8e672be40088bdb.tar.bz2 meta-impy-02dee1652be7868d588fefa8b8e672be40088bdb.tar.xz |
Ported some thread changes from Snowglobe.
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llqueuedthread.cpp | 49 | ||||
-rw-r--r-- | linden/indra/llcommon/llqueuedthread.h | 3 | ||||
-rw-r--r-- | linden/indra/llcommon/llworkerthread.cpp | 1 | ||||
-rw-r--r-- | linden/indra/llcommon/llworkerthread.h | 1 |
4 files changed, 31 insertions, 23 deletions
diff --git a/linden/indra/llcommon/llqueuedthread.cpp b/linden/indra/llcommon/llqueuedthread.cpp index cd53e70..aa62da8 100644 --- a/linden/indra/llcommon/llqueuedthread.cpp +++ b/linden/indra/llcommon/llqueuedthread.cpp | |||
@@ -450,26 +450,12 @@ S32 LLQueuedThread::processNextRequest() | |||
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | S32 res; | ||
454 | S32 pending = getPending(); | 453 | S32 pending = getPending(); |
455 | if (pending == 0) | 454 | |
456 | { | 455 | return pending; |
457 | if (isQuitting()) | ||
458 | { | ||
459 | res = -1; // exit thread | ||
460 | } | ||
461 | else | ||
462 | { | ||
463 | res = 0; | ||
464 | } | ||
465 | } | ||
466 | else | ||
467 | { | ||
468 | res = pending; | ||
469 | } | ||
470 | return res; | ||
471 | } | 456 | } |
472 | 457 | ||
458 | // virtual | ||
473 | bool LLQueuedThread::runCondition() | 459 | bool LLQueuedThread::runCondition() |
474 | { | 460 | { |
475 | // mRunCondition must be locked here | 461 | // mRunCondition must be locked here |
@@ -479,35 +465,52 @@ bool LLQueuedThread::runCondition() | |||
479 | return true; | 465 | return true; |
480 | } | 466 | } |
481 | 467 | ||
468 | // virtual | ||
482 | void LLQueuedThread::run() | 469 | void LLQueuedThread::run() |
483 | { | 470 | { |
471 | // call checPause() immediately so we don't try to do anything before the class is fully constructed | ||
472 | checkPause(); | ||
473 | startThread(); | ||
474 | |||
484 | while (1) | 475 | while (1) |
485 | { | 476 | { |
486 | // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. | 477 | // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. |
487 | checkPause(); | 478 | checkPause(); |
488 | 479 | ||
489 | if(isQuitting()) | 480 | if(isQuitting()) |
481 | { | ||
482 | endThread(); | ||
490 | break; | 483 | break; |
491 | 484 | } | |
492 | //llinfos << "QUEUED THREAD RUNNING, queue size = " << mRequestQueue.size() << llendl; | ||
493 | 485 | ||
494 | mIdleThread = FALSE; | 486 | mIdleThread = FALSE; |
495 | 487 | ||
488 | threadedUpdate(); | ||
489 | |||
496 | int res = processNextRequest(); | 490 | int res = processNextRequest(); |
497 | if (res == 0) | 491 | if (res == 0) |
498 | { | 492 | { |
499 | mIdleThread = TRUE; | 493 | mIdleThread = TRUE; |
494 | ms_sleep(1); | ||
495 | } | ||
496 | //LLThread::yield(); // thread should yield after each request | ||
497 | } | ||
498 | llinfos << "LLQueuedThread " << mName << " EXITING." << llendl; | ||
500 | } | 499 | } |
501 | 500 | ||
502 | if (res < 0) // finished working and want to exit | 501 | // virtual |
502 | void LLQueuedThread::startThread() | ||
503 | { | 503 | { |
504 | break; | ||
505 | } | 504 | } |
506 | 505 | ||
507 | //LLThread::yield(); // thread should yield after each request | 506 | // virtual |
507 | void LLQueuedThread::endThread() | ||
508 | { | ||
508 | } | 509 | } |
509 | 510 | ||
510 | llinfos << "QUEUED THREAD " << mName << " EXITING." << llendl; | 511 | // virtual |
512 | void LLQueuedThread::threadedUpdate() | ||
513 | { | ||
511 | } | 514 | } |
512 | 515 | ||
513 | //============================================================================ | 516 | //============================================================================ |
diff --git a/linden/indra/llcommon/llqueuedthread.h b/linden/indra/llcommon/llqueuedthread.h index 3ba43e1..aa7c6e4 100644 --- a/linden/indra/llcommon/llqueuedthread.h +++ b/linden/indra/llcommon/llqueuedthread.h | |||
@@ -165,6 +165,9 @@ private: | |||
165 | 165 | ||
166 | virtual bool runCondition(void); | 166 | virtual bool runCondition(void); |
167 | virtual void run(void); | 167 | virtual void run(void); |
168 | virtual void startThread(void); | ||
169 | virtual void endThread(void); | ||
170 | virtual void threadedUpdate(void); | ||
168 | 171 | ||
169 | protected: | 172 | protected: |
170 | handle_t generateHandle(); | 173 | handle_t generateHandle(); |
diff --git a/linden/indra/llcommon/llworkerthread.cpp b/linden/indra/llcommon/llworkerthread.cpp index 68d32db..8195e1c 100644 --- a/linden/indra/llcommon/llworkerthread.cpp +++ b/linden/indra/llcommon/llworkerthread.cpp | |||
@@ -196,6 +196,7 @@ LLWorkerClass::~LLWorkerClass() | |||
196 | { | 196 | { |
197 | llassert_always(!(mWorkFlags & WCF_WORKING)); | 197 | llassert_always(!(mWorkFlags & WCF_WORKING)); |
198 | llassert_always(mWorkFlags & WCF_DELETE_REQUESTED); | 198 | llassert_always(mWorkFlags & WCF_DELETE_REQUESTED); |
199 | llassert_always(!mMutex.isLocked()); | ||
199 | if (mRequestHandle != LLWorkerThread::nullHandle()) | 200 | if (mRequestHandle != LLWorkerThread::nullHandle()) |
200 | { | 201 | { |
201 | LLWorkerThread::WorkRequest* workreq = (LLWorkerThread::WorkRequest*)mWorkerThread->getRequest(mRequestHandle); | 202 | LLWorkerThread::WorkRequest* workreq = (LLWorkerThread::WorkRequest*)mWorkerThread->getRequest(mRequestHandle); |
diff --git a/linden/indra/llcommon/llworkerthread.h b/linden/indra/llcommon/llworkerthread.h index 19407f4..708d812 100644 --- a/linden/indra/llcommon/llworkerthread.h +++ b/linden/indra/llcommon/llworkerthread.h | |||
@@ -52,6 +52,7 @@ class LLWorkerClass; | |||
52 | 52 | ||
53 | class LLWorkerThread : public LLQueuedThread | 53 | class LLWorkerThread : public LLQueuedThread |
54 | { | 54 | { |
55 | friend class LLWorkerClass; | ||
55 | public: | 56 | public: |
56 | class WorkRequest : public LLQueuedThread::QueuedRequest | 57 | class WorkRequest : public LLQueuedThread::QueuedRequest |
57 | { | 58 | { |