Plasma Engine  2.0
Loading...
Searching...
No Matches
AtomicUtils.h
1#pragma once
2
3#include <Foundation/Basics.h>
4
14struct PL_FOUNDATION_DLL plAtomicUtils
15{
17 static plInt32 Read(const plInt32& iSrc); // [tested]
18
20 static plInt64 Read(const plInt64& iSrc); // [tested]
21
23 static plInt32 Increment(plInt32& ref_iDest); // [tested]
24
26 static plInt64 Increment(plInt64& ref_iDest); // [tested]
27
29 static plInt32 Decrement(plInt32& ref_iDest); // [tested]
30
32 static plInt64 Decrement(plInt64& ref_iDest); // [tested]
33
35 static plInt32 PostIncrement(plInt32& ref_iDest); // [tested]
36
38 static plInt64 PostIncrement(plInt64& ref_iDest); // [tested]
39
41 static plInt32 PostDecrement(plInt32& ref_iDest); // [tested]
42
44 static plInt64 PostDecrement(plInt64& ref_iDest); // [tested]
45
47 static void Add(plInt32& ref_iDest, plInt32 value); // [tested]
48
50 static void Add(plInt64& ref_iDest, plInt64 value); // [tested]
51
53 static void And(plInt32& ref_iDest, plInt32 value); // [tested]
54
56 static void And(plInt64& ref_iDest, plInt64 value); // [tested]
57
59 static void Or(plInt32& ref_iDest, plInt32 value); // [tested]
60
62 static void Or(plInt64& ref_iDest, plInt64 value); // [tested]
63
65 static void Xor(plInt32& ref_iDest, plInt32 value); // [tested]
66
68 static void Xor(plInt64& ref_iDest, plInt64 value); // [tested]
69
71 static void Min(plInt32& ref_iDest, plInt32 value); // [tested]
72
74 static void Min(plInt64& ref_iDest, plInt64 value); // [tested]
75
77 static void Max(plInt32& ref_iDest, plInt32 value); // [tested]
78
80 static void Max(plInt64& ref_iDest, plInt64 value); // [tested]
81
83 static plInt32 Set(plInt32& ref_iDest, plInt32 value); // [tested]
84
86 static plInt64 Set(plInt64& ref_iDest, plInt64 value); // [tested]
87
90 static bool TestAndSet(plInt32& ref_iDest, plInt32 iExpected, plInt32 value); // [tested]
91
94 static bool TestAndSet(plInt64& ref_iDest, plInt64 iExpected, plInt64 value); // [tested]
95
98 static bool TestAndSet(void** pDest, void* pExpected, void* value); // [tested]
99
102 static plInt32 CompareAndSwap(plInt32& ref_iDest, plInt32 iExpected, plInt32 value); // [tested]
103
106 static plInt64 CompareAndSwap(plInt64& ref_iDest, plInt64 iExpected, plInt64 value); // [tested]
107};
108
109// Include inline file
110#if PL_ENABLED(PL_PLATFORM_WINDOWS)
111# include <Foundation/Threading/Implementation/Win/AtomicUtils_win.h>
112#elif PL_ENABLED(PL_PLATFORM_OSX) || PL_ENABLED(PL_PLATFORM_LINUX) || PL_ENABLED(PL_PLATFORM_ANDROID)
113# include <Foundation/Threading/Implementation/Posix/AtomicUtils_posix.h>
114#else
115# error "Atomics are not implemented on current platform"
116#endif
This class provides functions to do atomic operations.
Definition AtomicUtils.h:15