Some code cleanup
This commit is contained in:
parent
02237aed8c
commit
a3510c5be8
@ -30,34 +30,6 @@
|
|||||||
#include <ace/Guard_T.h>
|
#include <ace/Guard_T.h>
|
||||||
#include <ace/Method_Request.h>
|
#include <ace/Method_Request.h>
|
||||||
|
|
||||||
class WDBThreadStartReq1 : public ACE_Method_Request
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
WDBThreadStartReq1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int call()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class WDBThreadEndReq1 : public ACE_Method_Request
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
WDBThreadEndReq1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int call()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MapUpdateRequest : public ACE_Method_Request
|
class MapUpdateRequest : public ACE_Method_Request
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -93,7 +65,7 @@ MapUpdater::~MapUpdater()
|
|||||||
|
|
||||||
int MapUpdater::activate(size_t num_threads)
|
int MapUpdater::activate(size_t num_threads)
|
||||||
{
|
{
|
||||||
return m_executor.activate((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1);
|
return m_executor.activate((int)num_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapUpdater::deactivate()
|
int MapUpdater::deactivate()
|
||||||
|
@ -34,18 +34,12 @@ DelayExecutor* DelayExecutor::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DelayExecutor::DelayExecutor()
|
DelayExecutor::DelayExecutor()
|
||||||
: pre_svc_hook_(0), post_svc_hook_(0), activated_(false)
|
: activated_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DelayExecutor::~DelayExecutor()
|
DelayExecutor::~DelayExecutor()
|
||||||
{
|
{
|
||||||
if (pre_svc_hook_)
|
|
||||||
delete pre_svc_hook_;
|
|
||||||
|
|
||||||
if (post_svc_hook_)
|
|
||||||
delete post_svc_hook_;
|
|
||||||
|
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +57,6 @@ int DelayExecutor::deactivate()
|
|||||||
|
|
||||||
int DelayExecutor::svc()
|
int DelayExecutor::svc()
|
||||||
{
|
{
|
||||||
if (pre_svc_hook_)
|
|
||||||
pre_svc_hook_->call();
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ACE_Method_Request* rq = queue_.dequeue();
|
ACE_Method_Request* rq = queue_.dequeue();
|
||||||
@ -77,13 +68,10 @@ int DelayExecutor::svc()
|
|||||||
delete rq;
|
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)
|
int DelayExecutor::activate(int num_threads)
|
||||||
{
|
{
|
||||||
if (activated())
|
if (activated())
|
||||||
return -1;
|
return -1;
|
||||||
@ -91,15 +79,6 @@ int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, A
|
|||||||
if (num_threads < 1)
|
if (num_threads < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (pre_svc_hook_)
|
|
||||||
delete pre_svc_hook_;
|
|
||||||
|
|
||||||
if (post_svc_hook_)
|
|
||||||
delete post_svc_hook_;
|
|
||||||
|
|
||||||
pre_svc_hook_ = pre_svc_hook;
|
|
||||||
post_svc_hook_ = post_svc_hook;
|
|
||||||
|
|
||||||
queue_.queue()->activate();
|
queue_.queue()->activate();
|
||||||
|
|
||||||
if (ACE_Task_Base::activate(THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, num_threads) == -1)
|
if (ACE_Task_Base::activate(THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, num_threads) == -1)
|
||||||
|
@ -40,7 +40,7 @@ class DelayExecutor : protected ACE_Task_Base
|
|||||||
|
|
||||||
int execute(ACE_Method_Request* new_req);
|
int execute(ACE_Method_Request* new_req);
|
||||||
|
|
||||||
int activate(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL);
|
int activate(int num_threads = 1);
|
||||||
|
|
||||||
int deactivate();
|
int deactivate();
|
||||||
|
|
||||||
@ -51,8 +51,6 @@ class DelayExecutor : protected ACE_Task_Base
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
ACE_Activation_Queue queue_;
|
ACE_Activation_Queue queue_;
|
||||||
ACE_Method_Request* pre_svc_hook_;
|
|
||||||
ACE_Method_Request* post_svc_hook_;
|
|
||||||
bool activated_;
|
bool activated_;
|
||||||
|
|
||||||
void activated(bool s);
|
void activated(bool s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user