Class ConcurrentBuffer
The concurrent data buffer allows to implement asynchronous data writing to the linear buffer by more than one worker thread at once. Supports only value types that don't require constructor/destructor invocation.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Threading/ConcurrentBuffer.h
Syntax
public class ConcurrentBuffer<T>
Type Parameters
|
T
|
Constructors
~ConcurrentBuffer()
ConcurrentBuffer()
ConcurrentBuffer(int32 capacity)
Initializes a new instance of the ConcurrentBuffer class.
Declaration
public ConcurrentBuffer(int32 capacity)
Parameters
|
int32
capacity
The capacity. |
Methods
Add(ConcurrentBuffer<T>& collection)
Adds a collection of items to the collection.
Declaration
public void Add(ConcurrentBuffer<T>& collection)
Parameters
|
ConcurrentBuffer<T>
collection
The collection of items to add. |
Returns
|
void
|
Add(const T& item)
Adds the single item to the collection. Handles automatic buffer resizing. Thread-safe function that can be called from many threads at once.
Declaration
public int64 Add(const T& item)
Parameters
|
T
item
The item to add. |
Returns
|
int64
The index of the added item. |
Add(const T* items, int32 count)
Adds the array of items to the collection. Handles automatic buffer resizing. Thread-safe function that can be called from many threads at once.
Declaration
public int64 Add(const T* items, int32 count)
Parameters
|
T
items
The collection of items to add. |
|
int32
count
The items count. |
Returns
|
int64
The index of the added first item. |
AddDefault(int32 count=1)
Adds the given amount of items to the collection.
Declaration
public int64 AddDefault(int32 count=1)
Parameters
|
int32
count
The items count. |
Returns
|
int64
The index of the added first item. |
AddOne()
Adds the one item to the collection and returns the reference to it.
Declaration
public T AddOne()
Returns
|
T
The reference to the added item. |
AddZeroed(int32 count=1)
Adds the new items to the end of the collection, possibly reallocating the whole collection to fit. The new items will be zeroed.
Warning! AddZeroed() will create items without calling the constructor and this is not appropriate for item types that require a constructor to function properly.
Declaration
public int64 AddZeroed(int32 count=1)
Parameters
|
int32
count
The number of new items to add. |
Returns
|
int64
The index of the added first item. |
Capacity()
Get amount of the elements that can be holed by collection without resizing.
Declaration
public int64 Capacity() const
Returns
|
int64
the items capacity. |
Clear()
Clear the collection but without changing its capacity.
Declaration
public void Clear()
Returns
|
void
|
Contains(const T& item)
Checks if the given element is in the collection.
Declaration
public bool Contains(const T& item) const
Parameters
|
T
item
The item. |
Returns
|
bool
|
Count()
Gets the amount of the elements in the collection.
Declaration
public int64 Count()
Returns
|
int64
The items count. |
EnsureCapacity(int64 minCapacity)
Ensures that the buffer has the given the capacity (equal or more). Preserves the existing items by copy operation.
Declaration
public void EnsureCapacity(int64 minCapacity)
Parameters
|
int64
minCapacity
The minimum capacity. |
First()
Gets the first element.
Declaration
public T First()
Returns
|
T
The first element reference. |
Get()
Gets the pointer to the first element in the collection.
Declaration
public T* Get()
Returns
|
T
The allocation start. |
HasItems()
Determines whether this collection isn't empty.
Declaration
public bool HasItems() const
Returns
|
bool
|
IndexOf(const T& item)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Declaration
public int32 IndexOf(const T& item) const
Parameters
|
T
item
The item. |
Returns
|
int32
The zero-based index of the first occurrence of item within the entire collection, if found; otherwise, INVALID_INDEX. |
IsEmpty()
Determines whether this collection is empty.
Declaration
public bool IsEmpty() const
Returns
|
bool
|
Last()
Gets the last element.
Declaration
public T Last()
Returns
|
T
The last element reference. |
operator[](int64 index)
Get or sets element by the index.
Declaration
public T operator[](int64 index)
Parameters
|
int64
index
The index. |
Returns
|
T
The item reference. |
Release()
Releases this buffer data.
Declaration
public void Release()
SetSize(int32 size)
Sets the custom size of the collection. Only for the custom usage with dedicated data.
Declaration
public void SetSize(int32 size)
Parameters
|
int32
size
The size. |
Swap(ConcurrentBuffer& other)
Swaps the contents of buffer with the other object without copy operation. Performs fast internal data exchange.
Declaration
public void Swap(ConcurrentBuffer& other)
Parameters
|
ConcurrentBuffer
other
The other buffer. |