Beispiel #1
0
        public TcpHandle(EventLoop loop) : base()
        {
            _handle    = Libuv.Allocate(uv_handle_type.UV_TCP);
            _eventLoop = loop;

            Libuv.uv_tcp_init(loop.Loop, _handle);

            GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);

            ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle);
        }
        protected NativeRequest(uv_req_type requestType, int size)
        {
            IntPtr handle = Libuv.Allocate(requestType);

            GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);

            *(IntPtr *)handle = GCHandle.ToIntPtr(gcHandle);

            this.Handle      = handle;
            this.requestType = requestType;
        }
Beispiel #3
0
        public Timer(EventLoop loop, Action <object> cb, object state)
        {
            _eventLoop = loop;
            _callback  = cb;
            _state     = state;

            _handle = Libuv.Allocate(uv_handle_type.UV_TIMER);

            Libuv.uv_timer_init(_eventLoop.Loop, _handle);


            GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);

            ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle);
        }
Beispiel #4
0
        public Async(EventLoop loop, Action <object> cb, object state)
        {
            var handle = Libuv.Allocate(uv_handle_type.UV_ASYNC);

            _handle = handle;

            _eventLoop = loop;

            _callback = cb;
            _state    = state;


            Libuv.uv_async_init(loop.Loop, _handle, WorkCallback);

            GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);

            ((uv_handle_t *)_handle)->data = GCHandle.ToIntPtr(gcHandle);
        }