refactor(Core): replace ACE atomic types with standard C++ (#3421)

* Update AuctionHouseHandler.cpp

* refactor(atomic-type): replace ACE atomic types

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: Kargatum <dowlandtop@yandex.com>
This commit is contained in:
Stefano Borzì
2020-09-08 10:41:01 +02:00
committed by GitHub
parent b93ed8740a
commit 4a9476bbfd
5 changed files with 11 additions and 9 deletions
+2 -1
View File
@@ -24,6 +24,7 @@
#include <ace/os_include/sys/os_types.h> #include <ace/os_include/sys/os_types.h>
#include <ace/os_include/sys/os_socket.h> #include <ace/os_include/sys/os_socket.h>
#include <atomic>
#include <set> #include <set>
#include "Log.h" #include "Log.h"
@@ -92,7 +93,7 @@ class ReactorRunnable : protected ACE_Task_Base
long Connections() long Connections()
{ {
return static_cast<long> (m_Connections); return m_Connections;
} }
int AddSocket (WorldSocket* sock) int AddSocket (WorldSocket* sock)
+2 -2
View File
@@ -83,7 +83,7 @@
#include "LuaEngine.h" #include "LuaEngine.h"
#endif #endif
ACE_Atomic_Op<ACE_Thread_Mutex, bool> World::m_stopEvent = false; std::atomic_long World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
uint32 World::m_worldLoopCounter = 0; uint32 World::m_worldLoopCounter = 0;
uint32 World::m_gameMSTime = 0; uint32 World::m_gameMSTime = 0;
@@ -2616,7 +2616,7 @@ void World::ShutdownMsg(bool show, Player* player)
void World::ShutdownCancel() void World::ShutdownCancel()
{ {
// nothing cancel or too later // nothing cancel or too later
if (!m_ShutdownTimer || m_stopEvent.value()) if (!m_ShutdownTimer || m_stopEvent)
return; return;
ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED;
+3 -3
View File
@@ -13,7 +13,6 @@
#include "Common.h" #include "Common.h"
#include "Timer.h" #include "Timer.h"
#include <ace/Atomic_Op.h>
#include "SharedDefines.h" #include "SharedDefines.h"
#include "QueryResult.h" #include "QueryResult.h"
#include "Callback.h" #include "Callback.h"
@@ -21,6 +20,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <list> #include <list>
#include <atomic>
class Object; class Object;
class WorldPacket; class WorldPacket;
@@ -723,7 +723,7 @@ class World
void ShutdownMsg(bool show = false, Player* player = nullptr); void ShutdownMsg(bool show = false, Player* player = nullptr);
static uint8 GetExitCode() { return m_ExitCode; } static uint8 GetExitCode() { return m_ExitCode; }
static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; } static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
static bool IsStopped() { return m_stopEvent.value(); } static bool IsStopped() { return m_stopEvent; }
void Update(uint32 diff); void Update(uint32 diff);
@@ -856,7 +856,7 @@ class World
void CalendarDeleteOldEvents(); void CalendarDeleteOldEvents();
void ResetGuildCap(); void ResetGuildCap();
private: private:
static ACE_Atomic_Op<ACE_Thread_Mutex, bool> m_stopEvent; static std::atomic_long m_stopEvent;
static uint8 m_ExitCode; static uint8 m_ExitCode;
uint32 m_ShutdownTimer; uint32 m_ShutdownTimer;
uint32 m_ShutdownMask; uint32 m_ShutdownMask;
@@ -48,7 +48,7 @@ int RASocket::handle_close(ACE_HANDLE /*handle*/, ACE_Reactor_Mask /*mask*/)
// While the above wait() will wait for the ::svc() to finish, it will not wait for the async event // While the above wait() will wait for the ::svc() to finish, it will not wait for the async event
// RASocket::commandfinished to be completed. Calling destroy() before the latter function ends // RASocket::commandfinished to be completed. Calling destroy() before the latter function ends
// will lead to using a freed pointer -> crash. // will lead to using a freed pointer -> crash.
while (_commandExecuting.value()) while (_commandExecuting)
ACE_OS::sleep(1); ACE_OS::sleep(1);
destroy(); destroy();
@@ -17,6 +17,7 @@
#include <ace/Svc_Handler.h> #include <ace/Svc_Handler.h>
#include <ace/SOCK_Stream.h> #include <ace/SOCK_Stream.h>
#include <ace/SOCK_Acceptor.h> #include <ace/SOCK_Acceptor.h>
#include <atomic>
/// Remote Administration socket /// Remote Administration socket
class RASocket : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH> class RASocket : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
@@ -44,7 +45,7 @@ class RASocket : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
private: private:
uint8 _minLevel; ///< Minimum security level required to connect uint8 _minLevel; ///< Minimum security level required to connect
ACE_Atomic_Op<ACE_Thread_Mutex, bool> _commandExecuting; std::atomic_long _commandExecuting;
}; };
#endif #endif