internal void Return(IChannel channel) { channel.Release(); if (_reliableChannels != null && channel is ReliableChannel reliableChannel) { _reliableChannels.TryEnqueue(reliableChannel); } if (_reliableFragmentedChannels != null && channel is ReliableFragmentedChannel reliableFragmentedChannel) { _reliableFragmentedChannels.TryEnqueue(reliableFragmentedChannel); } if (_reliableOrderedChannels != null && channel is ReliableOrderedChannel reliableOrderedChannel) { _reliableOrderedChannels.TryEnqueue(reliableOrderedChannel); } if (_reliableSequencedChannels != null && channel is ReliableSequencedChannel reliableSequencedChannel) { _reliableSequencedChannels.TryEnqueue(reliableSequencedChannel); } if (_reliableSequencedFragmentedChannels != null && channel is ReliableSequencedFragmentedChannel reliableSequencedFragmentedChannel) { _reliableSequencedFragmentedChannels.TryEnqueue(reliableSequencedFragmentedChannel); } if (_unreliableChannels != null && channel is UnreliableChannel unreliableChannel) { _unreliableChannels.TryEnqueue(unreliableChannel); } if (_unreliableOrderedChannels != null && channel is UnreliableOrderedChannel unreliableOrderedChannel) { _unreliableOrderedChannels.TryEnqueue(unreliableOrderedChannel); } if (_unreliableSequencedChannels != null && channel is UnreliableSequencedChannel unreliableSequencedChannel) { _unreliableSequencedChannels.TryEnqueue(unreliableSequencedChannel); } if (_unreliableRawChannels != null && channel is UnreliableRawChannel unreliableRawChannel) { _unreliableRawChannels.TryEnqueue(unreliableRawChannel); } }
internal void DeAlloc(MemoryWrapper wrapper) { if (wrapper.IsDead) { throw new MemoryException("Cannot deallocate already dead memory"); } wrapper.AllocatedMemory = null; wrapper.DirectMemory = null; wrapper.IsDead = true; if (!_pooledMemoryWrappers.TryEnqueue(wrapper)) { // Failed to enqueue pointers. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) { Logging.LogWarning("Could not return memory wrapper. The queue is full. The memory will be given to the garbage collector. [MEMORY WRAPPER]"); } } }
internal void DeAlloc(HeapPointers pointers) { if (pointers.IsDead) { throw new MemoryException("Cannot deallocate already dead memory"); } pointers.VirtualOffset = 0; pointers.VirtualCount = 0; pointers.IsDead = true; if (!_pooledPointerArrays.TryEnqueue(pointers)) { // Failed to enqueue pointers. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) { Logging.LogWarning("Could not return heap pointers. The queue is full. The memory will be given to the garbage collector. [HEAP POINTERS]"); } } }
internal void DeAlloc(HeapMemory memory) { if (memory.IsDead) { throw new MemoryException("Cannot deallocate already dead memory"); } memory.VirtualOffset = 0; memory.VirtualCount = 0; memory.IsDead = true; if (!_pooledHeapMemory.TryEnqueue(memory)) { // Failed to enqueue memory. Queue is full if (Logging.CurrentLogLevel <= LogLevel.Warning) { Logging.LogWarning("Could not return heap memory. The queue is full. The memory will be given to the garbage collector. [HEAP MEMORY]"); } } }