public void InvokeExceptionCaught(IChannelHandlerContext ctx, Exception cause) { Contract.Requires(cause != null); if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeExceptionCaughtNow(ctx, cause); } else { try { Executor.Execute( (c, e) => ChannelHandlerInvokerUtil.InvokeExceptionCaughtNow((IChannelHandlerContext)c, (Exception)e), ctx, cause); } catch (Exception t) { if (DefaultChannelPipeline.Logger.IsWarningEnabled) { DefaultChannelPipeline.Logger.Warning( "Failed to submit an ExceptionCaught() event. Cause: {0}", t); DefaultChannelPipeline.Logger.Warning( "The ExceptionCaught() event that was failed to submit was: {0}", cause); } } } }
public void InvokeChannelActive(IChannelHandlerContext ctx) { if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeChannelActiveNow(ctx); } else { Executor.Execute(c => ChannelHandlerInvokerUtil.InvokeChannelActiveNow((IChannelHandlerContext)c), ctx); } }
public void InvokeFlush(IChannelHandlerContext ctx) { if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeFlushNow(ctx); } else { Executor.Execute(InvokeFlushAction, ctx); } }
public void InvokeChannelWritabilityChanged(IChannelHandlerContext ctx) { if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeChannelWritabilityChangedNow(ctx); } else { Executor.Execute(InvokeChannelWritabilityChangedAction, ctx); } }
public void InvokeChannelReadComplete(IChannelHandlerContext ctx) { if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeChannelReadCompleteNow(ctx); } else { Executor.Execute(InvokeChannelReadCompleteAction, ctx); } }
public void InvokeChannelRead(IChannelHandlerContext ctx, object msg) { Contract.Requires(msg != null); if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeChannelReadNow(ctx, msg); } else { SafeProcessInboundMessage(InvokeChannelReadAction, ctx, msg); } }
public void InvokeUserEventTriggered(IChannelHandlerContext ctx, object evt) { Contract.Requires(evt != null); if (Executor.InEventLoop) { ChannelHandlerInvokerUtil.InvokeUserEventTriggeredNow(ctx, evt); } else { SafeProcessInboundMessage(InvokeUserEventTriggeredAction, ctx, evt); } }
public Task InvokeDeregisterAsync(IChannelHandlerContext ctx) { // todo: check for cancellation //if (!validatePromise(ctx, promise, false)) { // // promise cancelled // return; //} if (Executor.InEventLoop) { return(ChannelHandlerInvokerUtil.InvokeDeregisterAsyncNow(ctx)); } return(SafeExecuteOutboundAsync(() => ChannelHandlerInvokerUtil.InvokeDeregisterAsyncNow(ctx))); }
public Task InvokeBindAsync( IChannelHandlerContext ctx, EndPoint localAddress) { Contract.Requires(localAddress != null); // todo: check for cancellation //if (!validatePromise(ctx, promise, false)) { // // promise cancelled // return; //} if (Executor.InEventLoop) { return(ChannelHandlerInvokerUtil.InvokeBindAsyncNow(ctx, localAddress)); } return(SafeExecuteOutboundAsync(() => ChannelHandlerInvokerUtil.InvokeBindAsyncNow(ctx, localAddress))); }
public Task InvokeWriteAsync(IChannelHandlerContext ctx, object msg) { Contract.Requires(msg != null); // todo: check for cancellation //if (!validatePromise(ctx, promise, false)) { // // promise cancelled // return; //} if (Executor.InEventLoop) { return(ChannelHandlerInvokerUtil.InvokeWriteAsyncNow(ctx, msg)); } else { var promise = new TaskCompletionSource(); this.SafeExecuteOutbound(WriteTask.NewInstance(ctx, msg, promise), promise, msg); return(promise.Task); } }
public Task InvokeWriteAsync(IChannelHandlerContext ctx, object msg) { Contract.Requires(msg != null); // todo: check for cancellation //if (!validatePromise(ctx, promise, false)) { // // promise cancelled // return; //} if (Executor.InEventLoop) { return(ChannelHandlerInvokerUtil.InvokeWriteAsyncNow(ctx, msg)); } var channel = (AbstractChannel)ctx.Channel; var promise = new TaskCompletionSource(ctx); try { var size = channel.EstimatorHandle.Size(msg); if (size > 0) { var buffer = channel.Unsafe.OutboundBuffer; // Check for null as it may be set to null if the channel is closed already if (buffer != null) { buffer.IncrementPendingOutboundBytes(size); } } Executor.Execute(InvokeWriteAsyncAction, promise, msg); } catch (Exception cause) { ReferenceCountUtil.Release(msg); promise.TrySetException(cause); } return(promise.Task); }
public void Run() { try { ChannelOutboundBuffer buffer = this.ctx.Channel.Unsafe.OutboundBuffer; // Check for null as it may be set to null if the channel is closed already if (EstimateTaskSizeOnSubmit) { buffer?.DecrementPendingOutboundBytes(this.size); } ChannelHandlerInvokerUtil.InvokeWriteAsyncNow(this.ctx, this.msg).LinkOutcome(this.promise); } finally { // Set to null so the GC can collect them directly this.ctx = null; this.msg = null; this.promise = null; // recycle _handle.Free(this); } }