简介
异步请求队列,用于发起异步请求,请求在Task框架中执行。由ACE_Activation_Queue
和ACE_Method_Request
构成
结构
ACE_Activation_Queue
:allocator_
负责分配队列,data_block_allocator_
负责分配队列中的数据块
ACE_Method_Request
:其中call
为纯虚函数,priority_
用来表示消息的优先级
virtual int call (void) = 0;
应用
主要用在Task框架中
class Scheduler : public ACE_Task_Base
{
public:Scheduler (){ACE_TRACE ("Scheduler::Scheduler");this->activate ();}virtual int svc (void){ACE_TRACE ("Scheduler::svc");while (1){// Dequeue the next method objectauto_ptr<ACE_Method_Request>request (this->activation_queue_.dequeue ());// Invoke the method request.if (request->call () == -1)break;}return 0;}int enqueue (ACE_Method_Request *request){ACE_TRACE ("Scheduler::enqueue");return this->activation_queue_.enqueue (request);}private:ACE_Activation_Queue activation_queue_;
};class StatusUpdate : public ACE_Method_Request
{
public:StatusUpdate (HA_ControllerAgent& controller,ACE_Future<int>& returnVal): controller_(controller), returnVal_(returnVal){ACE_TRACE ("StatusUpdate::StatusUpdate");}virtual int call (void){ACE_TRACE ("StatusUpdate::call");// status_update with the controller.this->returnVal_.set (this->controller_.status_update ());return 0;}private:HA_ControllerAgent& controller_;ACE_Future<int> returnVal_;
};