feat(Core/Threading): replace ace threading (#4821)

This commit is contained in:
Kargatum
2021-04-17 00:45:29 +07:00
committed by GitHub
parent b9e84d8278
commit b2861be1cd
50 changed files with 300 additions and 342 deletions

View File

@@ -178,9 +178,6 @@ void PlayerMenu::ClearMenus()
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
{
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock1(_gossipMenu.GetLock());
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock2(_questMenu.GetLock());
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size
data << uint64(objectGUID);
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0

View File

@@ -5815,8 +5815,8 @@ void Player::ClearChannelWatch()
void Player::UpdateLocalChannels(uint32 newZone)
{
// pussywizard: mutex needed (tc changed opcode to THREAD UNSAFE)
static ACE_Thread_Mutex channelsLock;
ACORE_GUARD(ACE_Thread_Mutex, channelsLock);
static std::mutex channelsLock;
std::lock_guard<std::mutex> guard(channelsLock);
if (GetSession()->PlayerLoading() && !IsBeingTeleportedFar())
return; // The client handles it automatically after loading, but not after teleporting
@@ -14361,7 +14361,7 @@ void Player::TradeCancel(bool sendback)
void Player::UpdateSoulboundTradeItems()
{
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
if (m_itemSoulboundTradeable.empty())
return;
@@ -14385,14 +14385,14 @@ void Player::UpdateSoulboundTradeItems()
void Player::AddTradeableItem(Item* item)
{
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
m_itemSoulboundTradeable.push_back(item);
}
//TODO: should never allow an item to be added to m_itemSoulboundTradeable twice
void Player::RemoveTradeableItem(Item* item)
{
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
m_itemSoulboundTradeable.remove(item);
}

View File

@@ -2821,7 +2821,7 @@ protected:
EnchantDurationList m_enchantDuration;
ItemDurationList m_itemDuration;
ItemDurationList m_itemSoulboundTradeable;
ACE_Thread_Mutex m_soulboundTradableLock;
std::mutex m_soulboundTradableLock;
void ResetTimeSync();
void SendTimeSync();

View File

@@ -250,7 +250,7 @@ void MotionTransport::UpdatePosition(float x, float y, float z, float o)
void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
{
ACORE_GUARD(ACE_Thread_Mutex, Lock);
std::lock_guard<std::mutex> guard(Lock);
if (_passengers.insert(passenger).second)
{
if (Player* plr = passenger->ToPlayer())
@@ -279,7 +279,7 @@ void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
{
ACORE_GUARD(ACE_Thread_Mutex, Lock);
std::lock_guard<std::mutex> guard(Lock);
if (_passengers.erase(passenger) || _staticPassengers.erase(passenger))
{
if (Player* plr = passenger->ToPlayer())

View File

@@ -91,7 +91,7 @@ private:
bool _triggeredDepartureEvent;
PassengerSet _staticPassengers;
mutable ACE_Thread_Mutex Lock;
mutable std::mutex Lock;
bool _passengersLoaded;
bool _delayedTeleport;
};