public int InvokeAsyncRequest(OutgoingAsync outAsync, bool synchronous) { // // Increase the direct count to prevent the thread pool from being destroyed before // invokeAll is called. This will also throw if the object adapter has been deactivated. // _adapter.IncDirectCount(); int requestId = 0; try { lock (this) { outAsync.Cancelable(this); // This will throw if the request is canceled if (!outAsync.IsOneway) { requestId = ++_requestId; _asyncRequests.Add(requestId, outAsync); } _sendAsyncRequests.Add(outAsync, requestId); } } catch (System.Exception) { _adapter.DecDirectCount(); throw; } outAsync.AttachCollocatedObserver(_adapter, requestId); if (!synchronous || outAsync.IsOneway || _reference.InvocationTimeout > 0) { // Don't invoke from the user thread if async or invocation timeout is set // TODO: why is oneway included in this list? _adapter.ThreadPool.Dispatch( () => { if (SentAsync(outAsync)) { Debug.Assert(outAsync.RequestFrame != null); ValueTask vt = InvokeAllAsync(outAsync.RequestFrame, requestId); // TODO: do something with the value task } }); } else // Optimization: directly call invokeAll { if (SentAsync(outAsync)) { Debug.Assert(outAsync.RequestFrame != null); ValueTask vt = InvokeAllAsync(outAsync.RequestFrame, requestId); // TODO: do something with the value task } } return(OutgoingAsyncBase.AsyncStatusQueued); }
public void add(OutgoingAsync outAsync, int interval) { lock (this) { RetryTask task = new RetryTask(this, outAsync); _instance.timer().schedule(task, interval); _requests.Add(task, null); } }
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)); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock (this) { int requestId; if (_sendAsyncRequests.TryGetValue(outAsync, out requestId)) { if (requestId > 0) { _asyncRequests.Remove(requestId); } _sendAsyncRequests.Remove(outAsync); Ice.AsyncCallback cb = outAsync.completed(ex); if (cb != null) { outAsync.invokeCompletedAsync(cb); } _adapter.decDirectCount(); // invokeAll won't be called, decrease the direct count. return; } if (outAsync is OutgoingAsync) { OutgoingAsync o = (OutgoingAsync)outAsync; Debug.Assert(o != null); foreach (KeyValuePair <int, OutgoingAsyncBase> e in _asyncRequests) { if (e.Value == o) { _asyncRequests.Remove(e.Key); Ice.AsyncCallback cb = outAsync.completed(ex); if (cb != null) { outAsync.invokeCompletedAsync(cb); } return; } } } } }
public RetryTask(RetryQueue retryQueue, OutgoingAsync outAsync) { _retryQueue = retryQueue; _outAsync = outAsync; }
internal Request(OutgoingAsync @out) { this.@out = @out; }
public bool sendAsyncRequest(OutgoingAsync @out, out Ice.AsyncCallback sentCallback) { return(_connection.sendAsyncRequest(@out, _compress, _response, out sentCallback)); }