Selaa lähdekoodia

AtomicInt implementation for Windows

Dexter89 12 vuotta sitten
vanhempi
sitoutus
6182b0bf12
1 muutettua tiedostoa jossa 7 lisäystä ja 22 poistoa
  1. 7 22
      engine/os/win/AtomicInt.h

+ 7 - 22
engine/os/win/AtomicInt.h

@@ -27,6 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 #pragma once
 
 
 #include "Types.h"
 #include "Types.h"
+#include "windows.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -38,35 +39,19 @@ struct AtomicInt
 		m_value = value;
 		m_value = value;
 	}
 	}
 
 
-	AtomicInt& operator+=(int32_t value)
+	int load() const
 	{
 	{
-		InterlockedAdd(&m_value, value);
-		return *this;
-	}
-
-	AtomicInt& operator++(void)
-	{
-		InterlockedIncrement(&m_value);
-	}
-
-	AtomicInt& operator--(void)
-	{
-		InterlockedDecrement(&m_value);
-	}
-
-	AtomicInt& operator=(int32_t value)
-	{
-		InterlockedExchange(&m_value, value);
+		InterlockedExchangeAdd(&m_value, (int32_t)0);
+		return m_value;
 	}
 	}
 
 
-	operator int32_t()
+	void store(int val)
 	{
 	{
-		return m_value;
+		InterlockedExchange(&m_value, val);
 	}
 	}
 
 
 private:
 private:
-
-	LONG m_value;
+	mutable LONG m_value;
 };
 };
 
 
 } // namespace crown
 } // namespace crown