示例#1
0
        /// <summary>
        /// Allocate a new pinned T[] and return a PinnedArray instance;
        /// supposed to be callaed from managed code
        /// </summary>
        /// <param name="count">Length (number of elements) of the new array</param>
        /// <returns>Base address of the pinned array</returns>
        public PinnedArray <T> AllocatePinnedArray(int count)
        {
            var pinnedArray = new PinnedArray <T>(new T[count]);

            pool[pinnedArray.Address] = pinnedArray;
            return(pinnedArray);
        }
示例#2
0
 /// <summary>
 /// Unpin the given pinned array and remove it
 /// from the pool (deallocate)
 /// </summary>
 /// <param name="pinnedArray">The pinned array to unpin and remove from the pool</param>
 public void UnpinArray(PinnedArray <T> pinnedArray)
 {
     pinnedArray.Unpin();
     pool.Remove(pinnedArray.Address);
 }