Beispiel #1
0
        public static IntPtr AllocateFixedBuffer <T>(ulong length, ulong size, long timestamp, int tid, int rid, [CallerMemberName] string memberName = "", [CallerFilePath] string fileName = "", [CallerLineNumber] int lineNumber = 0)
        {
            IntPtr ptr = Jem.Calloc(length, size, memberName, fileName, lineNumber);

            if (ptr != IntPtr.Zero)
            {
                fixedBufferLock.EnterWriteLock();
                _FixedBufferAllocations.Add(ptr, new FixedBufferAllocation(ptr, length * size, timestamp, tid, rid));
                fixedBufferLock.ExitWriteLock();
            }
            return(ptr);
        }
Beispiel #2
0
 private unsafe bool Allocate(int length)
 {
     _Ptr = Jem.Calloc((ulong)length, ElementSizeInBytes);
     if (_Ptr != IntPtr.Zero)
     {
         _Length      = length;
         _SizeInBytes = (ulong)_Length * ElementSizeInBytes;
         _Timestamp   = DateTime.Now.Ticks;
         _VoidPointer = _Ptr.ToPointer();
         _Span        = new Span <T>(_VoidPointer, _Length);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        protected unsafe virtual IntPtr Allocate(int length)
        {
            if (length <= 0)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            Contract.EndContractBlock();
            ulong s = checked ((uint)length * ElementSizeInBytes);

            handle = Jem.Calloc((uint)length, ElementSizeInBytes);
            if (handle != IntPtr.Zero)
            {
                voidPtr     = handle.ToPointer();
                Length      = length;
                SizeInBytes = s;
                InitVector();
            }
            return(handle);
        }