aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llqueuedthread.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2010-02-08 17:25:48 -0600
committerJacek Antonelli2010-02-08 17:25:48 -0600
commit02dee1652be7868d588fefa8b8e672be40088bdb (patch)
treecafeaf4d499b53b745ba1b3c92c10c05f7382925 /linden/indra/llcommon/llqueuedthread.cpp
parentPorted many APR changes from Snowglobe. (diff)
downloadmeta-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.cpp49
1 files changed, 26 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
473bool LLQueuedThread::runCondition() 459bool 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
482void LLQueuedThread::run() 469void 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
502void LLQueuedThread::startThread()
503 { 503 {
504 break;
505 } 504 }
506 505
507 //LLThread::yield(); // thread should yield after each request 506// virtual
507void LLQueuedThread::endThread()
508{
508 } 509 }
509 510
510 llinfos << "QUEUED THREAD " << mName << " EXITING." << llendl; 511// virtual
512void LLQueuedThread::threadedUpdate()
513{
511} 514}
512 515
513//============================================================================ 516//============================================================================