Ejemplo n.º 1
0
        /// <summary>
        /// Create a buffer with at least the specified initial capacity in bytes.
        /// </summary>
        /// <exception cref="OverflowException">Thrown if trying to allocate more than a uint on 32bit.</exception>
        public HeapBuffer(ulong initialMinCapacity = 0)
        {
            _handle = HeapHandleCache.Instance.Acquire(initialMinCapacity);

            unsafe
            {
                _byteCapacity = (void *)(initialMinCapacity);
            }
        }
Ejemplo n.º 2
0
        private unsafe void ReleaseHandle()
        {
            HeapHandle handle;

            _handleLock.EnterWriteLock();
            try
            {
                handle        = _handle;
                _byteCapacity = null;
                _handle       = null;
            }
            finally
            {
                _handleLock.ExitWriteLock();
            }

            if (handle != null)
            {
                HeapHandleCache.Instance.Release(handle);
            }
        }