示例#1
0
文件: Proxy.cpp 项目: lmtoo/ice
ConnectionPtr
IceProxy::Ice::Object::ice_getConnection()
{
    InvocationObserver observer(this, ice_getConnection_name, ::Ice::noExplicitContext);
    int cnt = 0;
    while(true)
    {
        RequestHandlerPtr handler;
        try
        {
            handler = __getRequestHandler();
            return handler->waitForConnection(); // Wait for the connection to be established.
        }
        catch(const IceInternal::RetryException&)
        {
            __updateRequestHandler(handler, 0); // Clear request handler and retry.
        }
        catch(const Exception& ex)
        {
            try
            {
                int interval = __handleException(ex, handler, ICE_ENUM(OperationMode, Idempotent), false, cnt);
                observer.retried();
                if(interval > 0)
                {
                    IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
                }
            }
            catch(const Exception& exc)
            {
                observer.failed(exc.ice_id());
                throw;
            }
        }
    }
}