zoukankan      html  css  js  c++  java
  • ZeroC ICE的远程调用框架 AMD

    继上一篇《ZeroC ICE的远程调用框架》,本篇再来说其中的AMD。(本篇需要重写)

    当在ice文件中声明某个接口方法Method为["amd"]后,接口方法在stub类生成的远程调用框架代码不会变,但在skeleton类生成的就不是_iceD_Method和Method,而是_iceD_Method和Method_async。而amd模式和非amd模式的代码生成模板区别在于,_iceD_Method调用Method_async代替Method,并且在调用后不进行out方向参数的处理。另外还会生成AMD_Module_Method类,用于Method_aysnc的参数。

    在Ice远程调用中,有两种调用模式,Twoway和Oneway。Twoway的意是一个完整的请求包含一请求以及一应答,Oneway就是不需要这个应答。在Twoway模式下,即使声明接口方法返回void(即不返回结果),并且没有out方向的参数,skeleton类在完成接口调用后,还要写一个应答消息,消息包含应答状态,告诉代理端调用成功或失败。代理端的AsyncResult(即Future)也要阻塞或不阻塞等待这个应答消息。但是在amd模式(即Oneway)中,skeleton类在完成接口调用后,并不需要写回一个应答消息,代理端的AsyncResult也会忽略等待这个请求应答。

    void
    IceProxy::Ice::Object::_end(const ::Ice::AsyncResultPtr& result, const std::string& operation) const
    {
        AsyncResult::check(result, this, operation);
        bool ok = result->waitForResponse();
        if(_reference->getMode() == Reference::ModeTwoway)
        {
            if(!ok)
            {
                try
                {
                    result->throwUserException();
                }
                catch(const UserException& ex)
                {
                    throw UnknownUserException(__FILE__, __LINE__, ex.ice_id());
                }
            }
            result->readEmptyParams();
        }
    }
    bool
    Test::TestIntf::_iceD_Method(::IceInternal::Incoming& inS, const ::Ice::Current& current)
    {
        _iceCheckMode(::Ice::Normal, current.mode);
        inS.readEmptyParams();
        this->Method_async(new IceAsync::Test::AMD_TestIntf_startDispatch(inS), current);
        return true;
    }
  • 相关阅读:
    传输问题
    修改对象目录
    传输与系统单点登录问题
    两个小错误
    BW数据库优化过程记录20100529
    SAP ABAP 到外部数据库Oracle问题
    固定资产传输问题
    软件外包的商业模式和软件人员的职业规划
    做有意义的事,继续研究FarMap
    FarMap诞生了!
  • 原文地址:https://www.cnblogs.com/bbqzsl/p/6560589.html
Copyright © 2011-2022 走看看