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); }
protected void CreateHandle( LibuvFunctions uv, int threadId, int size, Action <Action <IntPtr>, IntPtr> queueCloseHandle) { _queueCloseHandle = queueCloseHandle; CreateMemory(uv, threadId, size); }
public void Init(LibuvFunctions uv) { CreateMemory( uv, Thread.CurrentThread.ManagedThreadId, uv.loop_size()); _uv.loop_init(this); }