unsafe public bool InitializeFromExistingHandle() { mutex = new Mutex(); if (mutex == null) { return(false); } // Mirror the existing memory buffer. We do not need actually to also fetch // the pointers since someone else has the ownership of that memory Buffers = new UnmanagedMemoryBuffer(); hostController = Controller.GetLocalController(); return(Buffers != null); }
unsafe public bool Initialize(ulong Size) { mutex = new Mutex(); if (mutex == null) { return(false); } UnmanagedMemoryBuffer NewBuffer = new UnmanagedMemoryBuffer(); if (NewBuffer != null) { uint overheadSize = MemoryStorage.GetMemoryStorageOveheadImpl(); if (!NewBuffer.AllocateBuffer(overheadSize + Size)) { return(false); } Buffers = NewBuffer; StorageHandle = MemoryStorage.MemoryStorageCreateImpl( QoS.StorageSettings, NewBuffer.GetBuffer(), (uint)NewBuffer.GetSize(), 0); if (Controller.GetLocalController().RegisterStorage(this)) { hostController = Controller.GetLocalController(); return(true); } } return(false); }
public override bool AddBuffer(ulong Size) { unsafe { UnmanagedMemoryBuffer NewBuffer = new UnmanagedMemoryBuffer(); if (NewBuffer != null) { if (!NewBuffer.AllocateBuffer(Size)) { return(false); } } mutex.AcquireMutex(); NewBuffer.Link = Buffers; Buffers = NewBuffer; mutex.ReleaseMutex(); MemoryStorage.MemoryStorageRegisterBufferImpl(StorageHandle, NewBuffer.GetBuffer(), (uint)NewBuffer.GetSize()); } return(true); }
public UnmanagedMemoryBuffer() { Link = null; }