Beispiel #1
0
        unsafe protected void CreateMemory(Uv uv, int threadId, int size)
        {
            _uv      = uv;
            ThreadId = threadId;

            handle            = Marshal.AllocCoTaskMem(size);
            *(IntPtr *)handle = GCHandle.ToIntPtr(GCHandle.Alloc(this, GCHandleType.Weak));
        }
Beispiel #2
0
        public void Init(Uv uv)
        {
            CreateMemory(
                uv,
                Thread.CurrentThread.ManagedThreadId,
                uv.loop_size());

            _uv.loop_init(this);
        }
Beispiel #3
0
 protected void CreateHandle(
     Uv uv,
     int threadId,
     int size,
     Action <Action <IntPtr>, IntPtr> queueCloseHandle)
 {
     _queueCloseHandle = queueCloseHandle;
     CreateMemory(uv, threadId, size);
 }
Beispiel #4
0
 protected void CreateHandle(
     Uv uv,
     int threadId,
     int size,
     Action<Action<IntPtr>, IntPtr> queueCloseHandle)
 {
     _queueCloseHandle = queueCloseHandle;
     CreateMemory(uv, threadId, size);
 }
Beispiel #5
0
        public void Init(Uv uv)
        {
            CreateMemory(
                uv,
                Thread.CurrentThread.ManagedThreadId,
                uv.loop_size());

            _uv.loop_init(this);
        }
Beispiel #6
0
        private void RunLoop()
        {
            Uv = new Uv();

            Loop = new UvLoopHandle();
            Loop.Init(Uv);

            _postHandle = new UvAsyncHandle();
            _postHandle.Init(Loop, OnPost, null);

            _running.Set();

            Uv.run(Loop, 0);

            _postHandle.Reference();
            _postHandle.Dispose();

            Uv.run(Loop, 0);

            Loop.Dispose();
        }
 private static void UvReadCb(IntPtr handle, int status, ref Uv.uv_buf_t buf)
 {
     var stream = FromIntPtr<UvStreamHandle>(handle);
     stream._readCallback(stream, status, stream._readState);
 }
 private static void UvAllocCb(IntPtr handle, int suggested_size, out Uv.uv_buf_t buf)
 {
     var stream = FromIntPtr<UvStreamHandle>(handle);
     try
     {
         buf = stream._allocCallback(stream, suggested_size, stream._readState);
     }
     catch
     {
         buf = stream.Libuv.buf_init(IntPtr.Zero, 0);
         throw;
     }
 }
 public int TryWrite(Uv.uv_buf_t buf)
 {
     return _uv.try_write(this, new[] { buf }, 1);
 }
Beispiel #10
0
 unsafe public void write2(UvRequest req, UvStreamHandle handle, Uv.uv_buf_t* bufs, int nbufs, UvStreamHandle sendHandle, uv_write_cb cb)
 {
     req.Validate();
     handle.Validate();
     ThrowIfErrored(_uv_write2(req, handle, bufs, nbufs, sendHandle, cb));
 }