void OnAllocateCallback(out uv_buf_t buf) { ReadOperation operation = this.unsafeChannel.PrepareRead(); this.pendingReads.Offer(operation); buf = operation.GetBuffer(); }
public Scratch() { byte[] scratch = ScratchBuf; _gcHandle = GCHandle.Alloc(scratch, GCHandleType.Pinned); IntPtr arrayHandle = _gcHandle.AddrOfPinnedObject(); Buf = new uv_buf_t(arrayHandle, scratch.Length); }
public Ping(NativeHandle sentHandle) : base(uv_req_type.UV_WRITE, 0) { _sentHandle = sentHandle; byte[] array = PingBuf; Bufs = new uv_buf_t[1]; GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); IntPtr arrayHandle = handle.AddrOfPinnedObject(); _gcHandle = handle; Bufs[0] = new uv_buf_t(arrayHandle, array.Length); }
static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf) { var tcp = GetTarget <Tcp>(handle); int status = (int)nread.ToInt64(); OperationException error = null; if (status < 0 && status != NativeMethods.EOF) { error = NativeMethods.CreateError((uv_err_code)status); } tcp.OnReadCallback(status, error); }
static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf) { var tcp = GetTarget <Tcp>(handle); int status = (int)nread.ToInt64(); OperationException error = null; if (status < 0 && status != (int)uv_err_code.UV_EOF) { error = NativeMethods.CreateError((uv_err_code)status); } ReadOperation operation = tcp.pendingReads.Poll(); if (operation == null) { if (error != null) { // It is possible if the client connection resets // causing errors where there are no pending read // operations, in this case we just notify the channel // for errors operation = new ReadOperation(tcp.unsafeChannel, Unpooled.Empty); } else { Logger.Warn("Channel read operation completed prematurely."); return; } } try { operation.Complete(status, error); } catch (Exception exception) { Logger.Warn("Channel read callbcak failed.", exception); } }
void OnAllocateCallback(out uv_buf_t buf) { buf = this.scratch.Buf; }
static void OnAllocateCallback(IntPtr handle, IntPtr suggestedSize, out uv_buf_t buf) { var pipe = GetTarget <Pipe>(handle); pipe.OnAllocateCallback(out buf); }
static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf) { var pipe = GetTarget <Pipe>(handle); pipe.OnReadCallback((int)nread.ToInt64()); }
static void OnAllocateCallback(IntPtr handle, IntPtr suggestedSize, out uv_buf_t buf) { var tcp = GetTarget <Tcp>(handle); tcp.OnAllocateCallback(out buf); }
void OnAllocateCallback(out uv_buf_t buf) { buf = _nativeUnsafe.PrepareRead(_pendingRead); }