diff options
author | XTZGZoReX <none@none> | 2010-04-05 13:08:47 +0200 |
---|---|---|
committer | XTZGZoReX <none@none> | 2010-04-05 13:08:47 +0200 |
commit | 7c277c87d8dffe89deee84592e337974fe0ef96e (patch) | |
tree | 4a7f53267c567f4f6377305d31b8b76d0f940fd6 /src/shared/DelayExecutor.cpp | |
parent | a795a1110c6b62df841b8a48d8e634ede255c486 (diff) |
* Only call Database::ThreadStart()/ThreadEnd() once per thread.
* Some cleanups in MapUpdater/DelayExecutor.
--HG--
branch : trunk
Diffstat (limited to 'src/shared/DelayExecutor.cpp')
-rw-r--r-- | src/shared/DelayExecutor.cpp | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/shared/DelayExecutor.cpp b/src/shared/DelayExecutor.cpp index 07a691d6357..9a718823232 100644 --- a/src/shared/DelayExecutor.cpp +++ b/src/shared/DelayExecutor.cpp @@ -4,16 +4,15 @@ #include "DelayExecutor.h" -DelayExecutor* -DelayExecutor::instance() +DelayExecutor* DelayExecutor::instance() { return ACE_Singleton<DelayExecutor, ACE_Thread_Mutex>::instance(); } -DelayExecutor::DelayExecutor(): -activated_ (false), -pre_svc_hook_ (0), -post_svc_hook_ (0) {} +DelayExecutor::DelayExecutor() + : activated_(false), pre_svc_hook_(0), post_svc_hook_(0) +{ +} DelayExecutor::~DelayExecutor() { @@ -23,49 +22,46 @@ DelayExecutor::~DelayExecutor() if (post_svc_hook_) delete post_svc_hook_; - this->deactivate (); + deactivate(); } int DelayExecutor::deactivate() { - if (!this->activated()) + if (!activated()) return -1; - this->activated(false); - - this->queue_.queue()->deactivate(); - - this->wait(); + activated(false); + queue_.queue()->deactivate(); + wait(); return 0; } -int DelayExecutor::svc (void) +int DelayExecutor::svc() { if (pre_svc_hook_) pre_svc_hook_->call(); for (;;) { - ACE_Method_Request* rq = this->queue_.dequeue(); + ACE_Method_Request* rq = queue_.dequeue(); - if (!rq) - break; + if (!rq) + break; - rq->call(); - - delete rq; + rq->call(); + delete rq; } if (post_svc_hook_) post_svc_hook_->call(); - return 0; + return 0; } int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) { - if (this->activated()) + if (activated()) return -1; if (num_threads < 1) @@ -77,15 +73,15 @@ int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, A if (post_svc_hook_) delete post_svc_hook_; - this->pre_svc_hook_ = pre_svc_hook; - this->post_svc_hook_ = post_svc_hook; + pre_svc_hook_ = pre_svc_hook; + post_svc_hook_ = post_svc_hook; - this->queue_.queue ()->activate (); + queue_.queue()->activate(); if (ACE_Task_Base::activate(THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, num_threads) == -1) - return -1; + return -1; - this->activated(true); + activated(true); return true; } @@ -95,20 +91,21 @@ int DelayExecutor::execute(ACE_Method_Request* new_req) if (new_req == NULL) return -1; - if (this->queue_.enqueue(new_req,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1) + if (queue_.enqueue(new_req, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1) { delete new_req; ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%t) %p\n"), ACE_TEXT("DelayExecutor::execute enqueue")), -1); } + return 0; } bool DelayExecutor::activated() { - return this->activated_; + return activated_; } void DelayExecutor::activated(bool s) { - this->activated_ = s; + activated_ = s; } |