示例#1
0
 public void add(OutgoingAsync outAsync, int interval)
 {
     lock(this)
     {
         RetryTask task = new RetryTask(this, outAsync);
         _instance.timer().schedule(task, interval);
         _requests.Add(task, null);
     }
 }
示例#2
0
 internal Request(OutgoingAsync @out)
 {
     this.@out = @out;
 }
示例#3
0
 public bool sendAsyncRequest(OutgoingAsync @out, out Ice.AsyncCallback sentCallback)
 {
     _m.Lock();
     try
     {
         if(!initialized())
         {
             _requests.AddLast(new Request(@out));
             sentCallback = null;
             return false;
         }
     }
     finally
     {
         _m.Unlock();
     }
     return _connection.sendAsyncRequest(@out, _compress, _response, out sentCallback);
 }
示例#4
0
 public RetryTask(RetryQueue retryQueue, OutgoingAsync outAsync)
 {
     _retryQueue = retryQueue;
     _outAsync = outAsync;
 }
        public bool invokeAsyncRequest(OutgoingAsync outAsync, bool synchronous, out Ice.AsyncCallback sentCallback)
        {
            int requestId = 0;
            {
                lock(this)
                {
                    outAsync.cancelable(this); // This will throw if the request is canceled

                    if(_response)
                    {
                        requestId = ++_requestId;
                        _asyncRequests.Add(requestId, outAsync);
                    }
                    _sendAsyncRequests.Add(outAsync, requestId);
                }
            }

            outAsync.attachCollocatedObserver(_adapter, requestId);

            if(synchronous)
            {
                //
                // Treat this collocated call as if it is a synchronous invocation.
                //
                if(_reference.getInvocationTimeout() > 0 || !_response)
                {
                    // Don't invoke from the user thread, invocation timeouts wouldn't work otherwise.
                    _adapter.getThreadPool().dispatch(() =>
                    {
                        if(sentAsync(outAsync))
                        {
                            invokeAll(outAsync.getOs(), requestId, 1, false);
                        }
                    }, null);
                }
                else if(_dispatcher)
                {
                    _adapter.getThreadPool().dispatchFromThisThread(() =>
                    {
                        if(sentAsync(outAsync))
                        {
                            invokeAll(outAsync.getOs(), requestId, 1, false);
                        }
                    }, null);
                }
                else // Optimization: directly call invokeAll if there's no dispatcher.
                {
                    if(sentAsync(outAsync))
                    {
                        invokeAll(outAsync.getOs(), requestId, 1, false);
                    }
                }
                sentCallback = null;
            }
            else
            {
                _adapter.getThreadPool().dispatch(() =>
                {
                    if(sentAsync(outAsync))
                    {
                        invokeAll(outAsync.getOs(), requestId, 1, false);
                    }
                }, null);
                sentCallback = null;
            }
            return false;
        }
 public bool sendAsyncRequest(OutgoingAsync @out, out Ice.AsyncCallback sentCallback)
 {
     return _connection.sendAsyncRequest(@out, _compress, _response, out sentCallback);
 }