2
0
Daniele Bartolini 6 жил өмнө
parent
commit
fb1a15ac3f

+ 0 - 40
src/core/thread/atomic_int.cpp

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2012-2020 Daniele Bartolini and individual contributors.
- * License: https://github.com/dbartolini/crown/blob/master/LICENSE
- */
-
-#include "core/platform.h"
-#include "core/thread/atomic_int.h"
-
-#if CROWN_PLATFORM_WINDOWS
-	#include <windows.h>
-#endif
-
-namespace crown
-{
-AtomicInt::AtomicInt(s32 val)
-	: _val(val)
-{
-}
-
-s32 AtomicInt::load()
-{
-#if CROWN_PLATFORM_POSIX && (CROWN_COMPILER_GCC || CROWN_COMPILER_CLANG)
-	__sync_fetch_and_add(&_val, 0);
-	return _val;
-#elif CROWN_PLATFORM_WINDOWS
-	InterlockedExchangeAdd((LONG*)&_val, (s32)0);
-	return _val;
-#endif
-}
-
-void AtomicInt::store(s32 val)
-{
-#if CROWN_PLATFORM_POSIX && (CROWN_COMPILER_GCC || CROWN_COMPILER_CLANG)
-	__sync_lock_test_and_set(&_val, val);
-#elif CROWN_PLATFORM_WINDOWS
-	InterlockedExchange((LONG*)&_val, val);
-#endif
-}
-
-} // namespace crown

+ 0 - 29
src/core/thread/atomic_int.h

@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012-2020 Daniele Bartolini and individual contributors.
- * License: https://github.com/dbartolini/crown/blob/master/LICENSE
- */
-
-#pragma once
-
-#include "core/types.h"
-
-namespace crown
-{
-/// Atomic integer.
-///
-/// @ingroup Thread
-struct AtomicInt
-{
-	s32 _val;
-
-	/// Initialization is not atomic.
-	AtomicInt(s32 val);
-
-	///
-	s32 load();
-
-	///
-	void store(s32 val);
-};
-
-} // namespace crown

+ 3 - 3
src/device/device_event_queue.inl

@@ -5,8 +5,8 @@
 
 #pragma once
 
-#include "core/thread/atomic_int.h"
 #include "device/types.h"
+#include <atomic>
 #include <string.h> // memcpy
 
 namespace crown
@@ -17,8 +17,8 @@ namespace crown
 /// @ingroup Device
 struct DeviceEventQueue
 {
-	CE_ALIGN_DECL(CROWN_CACHE_LINE_SIZE, AtomicInt _tail);
-	CE_ALIGN_DECL(CROWN_CACHE_LINE_SIZE, AtomicInt _head);
+	CE_ALIGN_DECL(CROWN_CACHE_LINE_SIZE, std::atomic_int _tail);
+	CE_ALIGN_DECL(CROWN_CACHE_LINE_SIZE, std::atomic_int _head);
 #define MAX_OS_EVENTS 128
 	OsEvent _queue[MAX_OS_EVENTS];