⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modulecontroller.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}// sendwait to another module controlled by another service.// throws Deadlock() if destination_q is this->queue_idAsyncReply* ModuleController::ModuleSendWait(    const RegisteredModuleHandle& handle,    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message){    if (false == verify_handle(const_cast<RegisteredModuleHandle *>(&handle)))        throw(Permission(Threads::self()));    return _send_wait(destination_q, destination_module, message);}void ModuleController::_async_handleEnqueue(    AsyncOpNode* op,    MessageQueue* q,    void* parm){    ModuleController* myself = static_cast<ModuleController *>(q);    Message* request = op->removeRequest();    Message* response = op->removeResponse();    if (request && (!(request->getMask() & MessageMask::ha_async)))        throw TypeMismatchException();    if (response && (!(response->getMask() & MessageMask::ha_async)))        throw TypeMismatchException();    op->release();    myself->return_op(op);    // get rid of the module wrapper    if (request && request->getType() == async_messages::ASYNC_MODULE_OP_START)    {        (static_cast<AsyncMessage *>(request))->op = NULL;        AsyncModuleOperationStart *rq =            static_cast<AsyncModuleOperationStart *>(request);        request = rq->get_action();        delete rq;    }    // get rid of the module wrapper    if (response &&        response->getType() == async_messages::ASYNC_MODULE_OP_RESULT)    {        (static_cast<AsyncMessage *>(response))->op = NULL;        AsyncModuleOperationResult *rp =            static_cast<AsyncModuleOperationResult *>(response);        response = rp->get_result();        delete rp;    }    callback_handle *cb = reinterpret_cast<callback_handle *>(parm);    cb->_module->_send_async_callback(0, response, cb->_parm);    delete cb;}// send an async message to a service asynchronouslyBoolean ModuleController::ModuleSendAsync(    const RegisteredModuleHandle& handle,    Uint32 msg_handle,    Uint32 destination_q,    AsyncRequest* message,    void* callback_parm){    if (false == verify_handle(const_cast<RegisteredModuleHandle *>(&handle)))        throw(Permission(Threads::self()));    if (message->op == NULL)    {        message->op = get_op();        message->op->setRequest(message);    }    callback_handle *cb = new callback_handle(        const_cast<RegisteredModuleHandle *>(&handle),        callback_parm);    message->resp = getQueueId();    message->block = false;    message->dest = destination_q;    return SendAsync(        message->op,        destination_q,        _async_handleEnqueue,        this,        cb);}// send a message to a module within another service asynchronouslyBoolean ModuleController::ModuleSendAsync(    const RegisteredModuleHandle& handle,    Uint32 msg_handle,    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message,    void* callback_parm){    if (false == verify_handle(const_cast<RegisteredModuleHandle *>(&handle)))        throw(Permission(Threads::self()));    AsyncOpNode *op = get_op();    AsyncModuleOperationStart *request = new AsyncModuleOperationStart(        op,        destination_q,        getQueueId(),        true,        destination_module,        message);    request->dest = destination_q;    callback_handle* cb = new callback_handle(        const_cast<RegisteredModuleHandle *>(&handle),        callback_parm);    return SendAsync(        op,        destination_q,        _async_handleEnqueue,        this,        cb);}Boolean ModuleController::_send_forget(    Uint32 destination_q,    AsyncRequest *message){    message->dest = destination_q;    return SendForget(message);}Boolean ModuleController::_send_forget(    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message){    AsyncOpNode* op = get_op();    message->dest = destination_q;    AsyncModuleOperationStart* request = new AsyncModuleOperationStart(        op,        destination_q,        getQueueId(),        true,        destination_module,        message);    return SendForget(request);}Boolean ModuleController::ModuleSendForget(    const RegisteredModuleHandle& handle,    Uint32 destination_q,    AsyncRequest* message){    if (false == verify_handle(const_cast<RegisteredModuleHandle *>(&handle)))        throw(Permission(Threads::self()));    return _send_forget(destination_q, message);}Boolean ModuleController::ModuleSendForget(    const RegisteredModuleHandle& handle,    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message){    if (false == verify_handle(const_cast<RegisteredModuleHandle *>(&handle)))        throw(Permission(Threads::self()));    return _send_forget(destination_q, destination_module, message);}void ModuleController::_handle_async_request(AsyncRequest* rq){    if (rq->getType() == async_messages::ASYNC_MODULE_OP_START)    {        // find the target module        RegisteredModuleHandle* target;        Message* module_result = NULL;        {            _module_lock lock(&_modules);            target = _modules.front();            while (target != NULL)            {                if (target->get_name() ==                        static_cast<AsyncModuleOperationStart *>(rq)->                            _target_module)                {                    break;                }                target = _modules.next_of(target);            }        }        if (target)        {            // ATTN: This statement was taken out of the _module_lock block            // above because that caused all requests to control providers to            // be serialized.  There is now a risk that the control provider            // module may be deleted after the lookup and before this call.            // See Bugzilla 3120.            module_result = target->_receive_message(                static_cast<AsyncModuleOperationStart *>(rq)->_act);        }        if (module_result == NULL)        {            module_result = new AsyncReply(                async_messages::REPLY,                MessageMask::ha_async | MessageMask::ha_reply,                rq->op,                async_results::CIM_NAK,                rq->resp,                false);        }        AsyncModuleOperationResult *result = new AsyncModuleOperationResult(            rq->op,            async_results::OK,            static_cast<AsyncModuleOperationStart *>(rq)->resp,            false,            static_cast<AsyncModuleOperationStart *>(rq)->_target_module,            module_result);        _complete_op_node(rq->op, 0, 0, 0);    }    else        Base::_handle_async_request(rq);}void ModuleController::_handle_async_callback(AsyncOpNode* op){    Base::_handle_async_callback(op);}ModuleController* ModuleController::getModuleController(){    MessageQueue* messageQueue =        MessageQueue::lookup(PEGASUS_QUEUENAME_CONTROLSERVICE);    PEGASUS_ASSERT(messageQueue != 0);    PEGASUS_ASSERT(messageQueue->isAsync());    MessageQueueService* service =        dynamic_cast<MessageQueueService*>(messageQueue);    PEGASUS_ASSERT(service != 0);    PEGASUS_ASSERT(        service->get_capabilities() & module_capabilities::module_controller);    return static_cast<ModuleController*>(service);}// send a message to another serviceAsyncReply* ModuleController::ClientSendWait(    Uint32 destination_q,    AsyncRequest* request){    return _send_wait(destination_q, request);}// send a message to another module via another serviceAsyncReply *ModuleController::ClientSendWait(    Uint32 destination_q,    String& destination_module,    AsyncRequest* request){    return _send_wait(destination_q, destination_module, request);}// send an async message to another serviceBoolean ModuleController::ClientSendAsync(    Uint32 msg_handle,    Uint32 destination_q,    AsyncRequest* message,    void (*async_callback)(Uint32, Message *, void *),    void* callback_parm){    RegisteredModuleHandle* temp = new RegisteredModuleHandle(        String(PEGASUS_MODULENAME_TEMP),        this,        0,        async_callback);   return ModuleSendAsync(        *temp,        msg_handle,        destination_q,        message,        callback_parm);}// send an async message to another module via another serviceBoolean ModuleController::ClientSendAsync(    Uint32 msg_handle,    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message,    void (*async_callback)(Uint32, Message *, void *),    void* callback_parm){    RegisteredModuleHandle* temp = new RegisteredModuleHandle(        String(PEGASUS_MODULENAME_TEMP),        this,        0,        async_callback);   return ModuleSendAsync(        *temp,        msg_handle,        destination_q,        destination_module,        message,        callback_parm);}Boolean ModuleController::ClientSendForget(    Uint32 destination_q,    AsyncRequest* message){    return _send_forget(destination_q, message);}Boolean ModuleController::ClientSendForget(    Uint32 destination_q,    const String& destination_module,    AsyncRequest* message){    return _send_forget(destination_q, destination_module, message);}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -