Limen Framework 0.1 Help

TAtomicArray

Overview

TAtomicArray is a template class designed to encapsulate an array (TArray) with thread safety. It uses a critical section (FCriticalSection) to ensure that insertions, pops, and other modifications are performed atomically. This makes it suitable for use in multi-threaded environments where concurrent access to the array is possible.

Properties

Type

Name

Access

Description

FCriticalSection

ArrayLock

Protected

A critical section used to synchronize access to the underlying array.

Functions

Return Type

Signature

Description

int32

Insert(const T& Element)

Inserts an element into the array atomically and returns its index.

int32

Insert(T&& Element)

Inserts a moveable element into the array atomically and returns its index.

T

PopAt(int32 Index)

Removes and returns the element at the specified index, ensuring atomicity.

void

RemoveInvalid()

Shrinks the array to remove any invalid elements, ensuring atomicity.

TArray<T>

Copy() const

Returns a copy of the array, ensuring atomicity during the copy operation.

Usage & Implementation Notes

  • The class uses FCriticalSection for synchronization, which ensures that all operations are thread-safe.

  • The Insert methods provide both lvalue and rvalue references to allow flexibility in how elements are added to the array.

  • The PopAt method safely removes an element by first copying it and then removing it from the array.

  • The RemoveInvalid method is used to optimize memory usage by removing any unused space in the array.

22 May 2026