當前位置: 首頁>>代碼示例>>C#>>正文


C# Networking.UvStreamHandle類代碼示例

本文整理匯總了C#中Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle的典型用法代碼示例。如果您正苦於以下問題:C# UvStreamHandle類的具體用法?C# UvStreamHandle怎麽用?C# UvStreamHandle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UvStreamHandle類屬於Microsoft.AspNet.Server.Kestrel.Networking命名空間,在下文中一共展示了UvStreamHandle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Shutdown

 public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
 {
     _callback = callback;
     _state = state;
     _pin = GCHandle.Alloc(this, GCHandleType.Normal);
     _uv.shutdown(this, handle, _uv_shutdown_cb);
 }
開發者ID:njmube,項目名稱:KestrelHttpServer,代碼行數:7,代碼來源:UvShutdownReq.cs

示例2: Shutdown

 public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
 {
     _callback = callback;
     _state = state;
     Pin();
     _uv.shutdown(this, handle, _uv_shutdown_cb);
 }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:7,代碼來源:UvShutdownReq.cs

示例3: SocketOutput

 public SocketOutput(KestrelThread thread, UvStreamHandle socket, long connectionId, IKestrelTrace log)
 {
     _thread = thread;
     _socket = socket;
     _connectionId = connectionId;
     _log = log;
     _callbacksPending = new Queue<CallbackContext>();
 }
開發者ID:rogeralsing,項目名稱:KestrelHttpServer,代碼行數:8,代碼來源:SocketOutput.cs

示例4: Write

        public unsafe void Write(
            UvStreamHandle handle,
            MemoryPoolIterator2 start,
            MemoryPoolIterator2 end,
            int nBuffers,
            Action<UvWriteReq, int, Exception, object> callback,
            object state)
        {
            try
            {
                // add GCHandle to keeps this SafeHandle alive while request processing
                _pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));

                var pBuffers = (Libuv.uv_buf_t*)_bufs;
                if (nBuffers > BUFFER_COUNT)
                {
                    // create and pin buffer array when it's larger than the pre-allocated one
                    var bufArray = new Libuv.uv_buf_t[nBuffers];
                    var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
                }

                var block = start.Block;
                for (var index = 0; index < nBuffers; index++)
                {
                    var blockStart = block == start.Block ? start.Index : block.Data.Offset;
                    var blockEnd = block == end.Block ? end.Index : block.Data.Offset + block.Data.Count;

                    // create and pin each segment being written
                    pBuffers[index] = Libuv.buf_init(
                        block.Pin() + blockStart,
                        blockEnd - blockStart);

                    block = block.Next;
                }

                _callback = callback;
                _state = state;
                _uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
            }
            catch
            {
                _callback = null;
                _state = null;
                Unpin(this);

                var block = start.Block;
                for (var index = 0; index < nBuffers; index++)
                {
                    block.Unpin();
                    block = block.Next;
                }

                throw;
            }
        }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:57,代碼來源:UvWriteReq.cs

示例5: Connection

        public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
        {
            _socket = socket;
            ConnectionControl = this;

            _connectionId = Interlocked.Increment(ref _lastConnectionId);

            _rawSocketInput = new SocketInput(Memory2, ThreadPool);
            _rawSocketOutput = new SocketOutput(Thread, _socket, Memory2, this, _connectionId, Log, ThreadPool, WriteReqPool);
        }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:10,代碼來源:Connection.cs

示例6: Connection

        public Connection(ListenerContext context, UvStreamHandle socket)
            : base(context)
        {
            _socket = socket;
            ConnectionControl = this;

            _connectionId = Interlocked.Increment(ref _lastConnectionId);

            SocketInput = new SocketInput(Memory2);
            SocketOutput = new SocketOutput(Thread, _socket, _connectionId, Log);
            _frame = new Frame(this);
        }
開發者ID:rogeralsing,項目名稱:KestrelHttpServer,代碼行數:12,代碼來源:Connection.cs

示例7: ConnectionCallback

 protected static void ConnectionCallback(UvStreamHandle stream, int status, Exception error, object state)
 {
     var listener = (Listener) state;
     if (error != null)
     {
         listener.Log.LogError("Listener.ConnectionCallback ", error);
     }
     else
     {
         listener.OnConnection(stream, status);
     }
 }
開發者ID:Starcounter,項目名稱:KestrelHttpServer,代碼行數:12,代碼來源:Listener.cs

示例8: Write

        public unsafe void Write(
            UvStreamHandle handle,
            ArraySegment<ArraySegment<byte>> bufs,
            Action<UvWriteReq, int, Exception, object> callback,
            object state)
        {
            try
            {
                // add GCHandle to keeps this SafeHandle alive while request processing
                _pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));

                var pBuffers = (Libuv.uv_buf_t*)_bufs;
                var nBuffers = bufs.Count;
                if (nBuffers > BUFFER_COUNT)
                {
                    // create and pin buffer array when it's larger than the pre-allocated one
                    var bufArray = new Libuv.uv_buf_t[nBuffers];
                    var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
                }

                for (var index = 0; index != nBuffers; ++index)
                {
                    // create and pin each segment being written
                    var buf = bufs.Array[bufs.Offset + index];

                    var gcHandle = GCHandle.Alloc(buf.Array, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers[index] = Libuv.buf_init(
                        gcHandle.AddrOfPinnedObject() + buf.Offset,
                        buf.Count);
                }

                _callback = callback;
                _state = state;
                _uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
            }
            catch
            {
                _callback = null;
                _state = null;
                Unpin(this);
                throw;
            }
        }
開發者ID:justkao,項目名稱:KestrelHttpServer,代碼行數:46,代碼來源:UvWriteReq.cs

示例9: OnConnection

        /// <summary>
        /// Handles an incoming connection
        /// </summary>
        /// <param name="listenSocket">Socket being used to listen on</param>
        /// <param name="status">Connection status</param>
        protected override void OnConnection(UvStreamHandle listenSocket, int status)
        {
            var acceptSocket = new UvTcpHandle(Log);
            acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);

            try
            {
                listenSocket.Accept(acceptSocket);
            }
            catch (UvException ex)
            {
                Log.LogError("TcpListenerPrimary.OnConnection", ex);
                return;
            }

            DispatchConnection(acceptSocket);
        }
開發者ID:rogeralsing,項目名稱:KestrelHttpServer,代碼行數:22,代碼來源:TcpListenerPrimary.cs

示例10: OnConnection

        /// <summary>
        /// Handles an incoming connection
        /// </summary>
        /// <param name="listenSocket">Socket being used to listen on</param>
        /// <param name="status">Connection status</param>
        protected override void OnConnection(UvStreamHandle listenSocket, int status)
        {
            var acceptSocket = new UvPipeHandle(Log);
            acceptSocket.Init(Thread.Loop, false);

            try
            {
                listenSocket.Accept(acceptSocket);
            }
            catch (UvException ex)
            {
                Log.LogError("PipeListener.OnConnection", ex);
                return;
            }

            DispatchConnection(acceptSocket);
        }
開發者ID:Starcounter,項目名稱:KestrelHttpServer,代碼行數:22,代碼來源:PipeListener.cs

示例11: OnListenPipe

        private void OnListenPipe(UvStreamHandle pipe, int status, Exception error, object state)
        {
            if (status < 0)
            {
                return;
            }

            var dispatchPipe = new UvPipeHandle();
            dispatchPipe.Init(Thread.Loop, true);
            try
            {
                pipe.Accept(dispatchPipe);
            }
            catch (Exception)
            {
                dispatchPipe.Dispose();
                return;
            }
            _dispatchPipes.Add(dispatchPipe);
        }
開發者ID:justkao,項目名稱:KestrelHttpServer,代碼行數:20,代碼來源:ListenerPrimary.cs

示例12: OnListenPipe

        private void OnListenPipe(UvStreamHandle pipe, int status, Exception error)
        {
            if (status < 0)
            {
                return;
            }

            var dispatchPipe = new UvPipeHandle(Log);
            dispatchPipe.Init(Thread.Loop, true);

            try
            {
                pipe.Accept(dispatchPipe);
            }
            catch (UvException ex)
            {
                dispatchPipe.Dispose();
                Log.LogError("ListenerPrimary.OnListenPipe", ex);
                return;
            }

            _dispatchPipes.Add(dispatchPipe);
        }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:23,代碼來源:ListenerPrimary.cs

示例13: DispatchConnection

 protected override void DispatchConnection(UvStreamHandle socket)
 {
     var index = _dispatchIndex++ % (_dispatchPipes.Count + 1);
     if (index == _dispatchPipes.Count)
     {
         base.DispatchConnection(socket);
     }
     else
     {
         var dispatchPipe = _dispatchPipes[index];
         var write = new UvWriteReq(Log);
         write.Init(Thread.Loop);
         write.Write2(
             dispatchPipe,
             _dummyMessage,
             socket,
             (write2, status, error, state) => 
             {
                 write2.Dispose();
                 ((UvStreamHandle)state).Dispose();
             },
             socket);
     }
 }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:24,代碼來源:ListenerPrimary.cs

示例14: SocketOutput

        public SocketOutput(
            KestrelThread thread,
            UvStreamHandle socket,
            MemoryPool2 memory,
            Connection connection,
            long connectionId,
            IKestrelTrace log,
            IThreadPool threadPool,
            Queue<UvWriteReq> writeReqPool)
        {
            _thread = thread;
            _socket = socket;
            _connection = connection;
            _connectionId = connectionId;
            _log = log;
            _threadPool = threadPool;
            _tasksPending = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _tasksCompleted = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _writeContextPool = new Queue<WriteContext>(_maxPooledWriteContexts);
            _writeReqPool = writeReqPool;

            _head = memory.Lease();
            _tail = _head;
        }
開發者ID:leloulight,項目名稱:KestrelHttpServer,代碼行數:24,代碼來源:SocketOutput.cs

示例15: Contextualize

 internal void Contextualize(
     SocketOutput socketOutput,
     UvStreamHandle socket,
     ArraySegment<byte> buffer,
     Action<Exception, object> callback,
     object state)
 {
     _self = socketOutput;
     _socket = socket;
     _buffer = buffer;
     _callback = callback;
     _state = state;
 }
開發者ID:fakedob,項目名稱:KestrelHttpServer,代碼行數:13,代碼來源:SocketOutput.cs


注:本文中的Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。