Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FThreadSafeCounter Class Reference

#include <ThreadSafeCounter.h>

+ Inheritance diagram for FThreadSafeCounter:

Public Types

typedef int32 IntegerType
 

Public Member Functions

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

Private Member Functions

void operator= (const FThreadSafeCounter &Other)
 

Private Attributes

volatile int32 Counter
 

Detailed Description

Thread safe counter

Definition at line 13 of file ThreadSafeCounter.h.

Member Typedef Documentation

◆ IntegerType

Constructor & Destructor Documentation

◆ FThreadSafeCounter() [1/3]

FThreadSafeCounter::FThreadSafeCounter ( )
inline

Default constructor.

Initializes the counter to 0.

Definition at line 23 of file ThreadSafeCounter.h.

◆ FThreadSafeCounter() [2/3]

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

Definition at line 41 of file ThreadSafeCounter.h.

+ Here is the call graph for this function:

◆ FThreadSafeCounter() [3/3]

FThreadSafeCounter::FThreadSafeCounter ( int32 Value)
inline

Constructor, initializing counter to passed in value.

Parameters
ValueValue to initialize counter to

Definition at line 55 of file ThreadSafeCounter.h.

+ Here is the caller graph for this function:

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

Definition at line 82 of file ThreadSafeCounter.h.

◆ Decrement()

int32 FThreadSafeCounter::Decrement ( )
inline

Decrement and return new value.

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

Definition at line 93 of file ThreadSafeCounter.h.

+ Here is the caller graph for this function:

◆ GetValue()

int32 FThreadSafeCounter::GetValue ( ) const
inline

Gets the current value.

Returns
the current value

Definition at line 138 of file ThreadSafeCounter.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Increment()

int32 FThreadSafeCounter::Increment ( )
inline

Increment and return new value.

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

Definition at line 70 of file ThreadSafeCounter.h.

+ Here is the caller graph for this function:

◆ operator=()

void FThreadSafeCounter::operator= ( const FThreadSafeCounter & Other)
inlineprivate

Hidden on purpose as usage wouldn't be thread safe.

Definition at line 146 of file ThreadSafeCounter.h.

◆ Reset()

int32 FThreadSafeCounter::Reset ( )
inline

Resets the counter's value to zero.

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

Definition at line 128 of file ThreadSafeCounter.h.

◆ 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

Definition at line 117 of file ThreadSafeCounter.h.

+ Here is the caller graph for this function:

◆ 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

Definition at line 105 of file ThreadSafeCounter.h.

Member Data Documentation

◆ Counter

volatile int32 FThreadSafeCounter::Counter
private

Thread-safe counter

Definition at line 149 of file ThreadSafeCounter.h.


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