Esempio n. 1
0
        protected override bool ReleaseHandle()
        {
            IntPtr memory = handle;

            if (memory != IntPtr.Zero)
            {
                handle = IntPtr.Zero;

                if (Thread.CurrentThread.ManagedThreadId == ThreadId)
                {
                    _uv.close(memory, _destroyMemory);
                }
                else if (_queueCloseHandle != null)
                {
                    // This can be called from the finalizer.
                    // Ensure the closure doesn't reference "this".
                    LibuvFunctions uv = _uv;
                    _queueCloseHandle(memory2 => uv.close(memory2, _destroyMemory), memory);
                }
                else
                {
                    Debug.Assert(false, "UvHandle not initialized with queueCloseHandle action");
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
 protected void CreateHandle(
     LibuvFunctions uv,
     int threadId,
     int size,
     Action <Action <IntPtr>, IntPtr> queueCloseHandle)
 {
     _queueCloseHandle = queueCloseHandle;
     CreateMemory(uv, threadId, size);
 }
Esempio n. 3
0
        public void Init(LibuvFunctions uv)
        {
            CreateMemory(
                uv,
                Thread.CurrentThread.ManagedThreadId,
                uv.loop_size());

            _uv.loop_init(this);
        }