UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FThreadSafeCounter Class Reference

#include <ThreadSafeCounter.h>

+ Inheritance diagram for FThreadSafeCounter:

Public Types

using IntegerType = int32
 

Public Member Functions

 FThreadSafeCounter (int32 Value=0)
 
 FThreadSafeCounter (const FThreadSafeCounter &Other)
 
int32 Increment ()
 
int32 Add (int32 Amount)
 
int32 Decrement ()
 
int32 Subtract (int32 Amount)
 
int32 Set (int32 Value)
 
int32 Reset ()
 
int32 GetValue () const
 

Detailed Description

Thread safe counter

Member Typedef Documentation

◆ IntegerType

Constructor & Destructor Documentation

◆ FThreadSafeCounter() [1/2]

FThreadSafeCounter::FThreadSafeCounter ( int32  Value = 0)
inline

Constructor, initializing counter to passed in value.

Parameters
ValueValue to initialize counter to

◆ FThreadSafeCounter() [2/2]

FThreadSafeCounter::FThreadSafeCounter ( const FThreadSafeCounter Other)
inline

Copy Constructor.

If the counter in the Other parameter is changing from other threads, there are no guarantees as to which values you will get up to the caller to not care, synchronize or other way to make those guarantees.

Parameters
OtherThe other thread safe counter to copy

Member Function Documentation

◆ Add()

int32 FThreadSafeCounter::Add ( int32  Amount)
inline

Adds an amount and returns the old value.

Parameters
AmountAmount to increase the counter by
Returns
the old value
See also
Decrement, Increment, Reset, Set, Subtract

◆ Decrement()

int32 FThreadSafeCounter::Decrement ( )
inline

Decrement and return new value.

Returns
the new, decremented value
See also
Add, Increment, Reset, Set, Subtract

◆ GetValue()

int32 FThreadSafeCounter::GetValue ( ) const
inline

Gets the current value.

Returns
the current value

◆ Increment()

int32 FThreadSafeCounter::Increment ( )
inline

Increment and return new value.

Returns
the new, incremented value
See also
Add, Decrement, Reset, Set, Subtract

◆ Reset()

int32 FThreadSafeCounter::Reset ( )
inline

Resets the counter's value to zero.

Returns
the old value.
See also
Add, Decrement, Increment, Set, Subtract

◆ Set()

int32 FThreadSafeCounter::Set ( int32  Value)
inline

Sets the counter to a specific value and returns the old value.

Parameters
ValueValue to set the counter to
Returns
The old value
See also
Add, Decrement, Increment, Reset, Subtract

◆ Subtract()

int32 FThreadSafeCounter::Subtract ( int32  Amount)
inline

Subtracts an amount and returns the old value.

Parameters
AmountAmount to decrease the counter by
Returns
the old value
See also
Add, Decrement, Increment, Reset, Set

The documentation for this class was generated from the following file: