Struct AtomicFreeList<T>
A generic, multiple-reader, multiple-writer concurrent free list
Namespace: Unity.Media.Utilities
Syntax
public struct AtomicFreeList<T> : IDisposable, IValidatable, IEquatable<AtomicFreeList<T>> where T : struct
Type Parameters
Name | Description |
---|---|
T | The element type for the list. For technical reasons, the size of T must be at least the size of AtomicNode. |
Constructors
AtomicFreeList(AllocationMode, Allocator)
Create a new AtomicFreeList
Declaration
public AtomicFreeList(AllocationMode allocationMode, Allocator allocator = null)
Parameters
Type | Name | Description |
---|---|---|
AllocationMode | allocationMode | The allocation mode to be used |
Allocator | allocator | The native allocator to be used |
Properties
Valid
Whether the free list is valid
Declaration
public bool Valid { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Methods
Acquire(out T*)
Acquires a new element from the free list. If no elements are available, or the allocation mode is ephemeral, a new element is allocated.
Declaration
public bool Acquire(out T*element)
Parameters
Type | Name | Description |
---|---|---|
T* | element | A "new" element is stored here |
Returns
Type | Description |
---|---|
Boolean | True if an element was reused from the pool, otherwise false |
Dispose()
Disposes the free list and releases all freed elements
Declaration
public void Dispose()
Equals(Object)
Whether this is the same free list as another instance
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The free list to compare |
Returns
Type | Description |
---|---|
Boolean |
Equals(AtomicFreeList<T>)
Whether this is the same free list as another instance
Declaration
public bool Equals(AtomicFreeList<T> other)
Parameters
Type | Name | Description |
---|---|---|
AtomicFreeList<T> | other | The free list to compare |
Returns
Type | Description |
---|---|
Boolean |
GetHashCode()
Return a unique hash code for this free list
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Release(T*)
Releases an element into the free list
Declaration
public void Release(T*element)
Parameters
Type | Name | Description |
---|---|---|
T* | element | The element to be released |
Remarks
If the allocation mode is ephemeral, the element will be freed immediately