mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Remove ACE and boost RW mutex requirements
This commit is contained in:
14
BindingMap.h
14
BindingMap.h
@@ -23,7 +23,7 @@ extern "C"
|
||||
* A set of bindings from keys of type `K` to Lua references.
|
||||
*/
|
||||
template<typename K>
|
||||
class BindingMap : public ElunaUtil::RWLockable
|
||||
class BindingMap : public ElunaUtil::Lockable
|
||||
{
|
||||
private:
|
||||
lua_State* L;
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
*/
|
||||
uint64 Insert(const K& key, int ref, uint32 shots)
|
||||
{
|
||||
WriteGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
uint64 id = (++maxBindingID);
|
||||
BindingList& list = bindings[key];
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
*/
|
||||
void Clear(const K& key)
|
||||
{
|
||||
WriteGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
if (bindings.empty())
|
||||
return;
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
WriteGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
if (bindings.empty())
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
*/
|
||||
void Remove(uint64 id)
|
||||
{
|
||||
WriteGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
auto iter = id_lookup_table.find(id);
|
||||
if (iter == id_lookup_table.end())
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
*/
|
||||
bool HasBindingsFor(const K& key)
|
||||
{
|
||||
ReadGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
if (bindings.empty())
|
||||
return false;
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
*/
|
||||
void PushRefsFor(const K& key)
|
||||
{
|
||||
WriteGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
|
||||
if (bindings.empty())
|
||||
return;
|
||||
|
||||
@@ -18,7 +18,7 @@ ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
EventMgr::WriteGuard guard((*E)->eventMgr->GetLock());
|
||||
EventMgr::Guard guard((*E)->eventMgr->GetLock());
|
||||
(*E)->eventMgr->processors.insert(this);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ ElunaEventProcessor::~ElunaEventProcessor()
|
||||
|
||||
if (obj && Eluna::IsInitialized())
|
||||
{
|
||||
EventMgr::WriteGuard guard((*E)->eventMgr->GetLock());
|
||||
EventMgr::Guard guard((*E)->eventMgr->GetLock());
|
||||
(*E)->eventMgr->processors.erase(this);
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ EventMgr::EventMgr(Eluna** _E) : globalProcessor(new ElunaEventProcessor(_E, NUL
|
||||
EventMgr::~EventMgr()
|
||||
{
|
||||
{
|
||||
ReadGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
if (!processors.empty())
|
||||
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
|
||||
(*it)->RemoveEvents_internal();
|
||||
@@ -136,7 +136,7 @@ EventMgr::~EventMgr()
|
||||
|
||||
void EventMgr::SetStates(LuaEventState state)
|
||||
{
|
||||
ReadGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
if (!processors.empty())
|
||||
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
|
||||
(*it)->SetStates(state);
|
||||
@@ -145,7 +145,7 @@ void EventMgr::SetStates(LuaEventState state)
|
||||
|
||||
void EventMgr::SetState(int eventId, LuaEventState state)
|
||||
{
|
||||
ReadGuard guard(GetLock());
|
||||
Guard guard(GetLock());
|
||||
if (!processors.empty())
|
||||
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
|
||||
(*it)->SetState(eventId, state);
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
Eluna** E;
|
||||
};
|
||||
|
||||
class EventMgr : public ElunaUtil::RWLockable
|
||||
class EventMgr : public ElunaUtil::Lockable
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_set<ElunaEventProcessor*> ProcessorSet;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ObjectGuid.h"
|
||||
@@ -21,20 +23,6 @@
|
||||
#include "Database/QueryResult.h"
|
||||
#endif
|
||||
|
||||
// Some dummy includes containing BOOST_VERSION:
|
||||
// ObjectAccessor.h Config.h Log.h
|
||||
#ifndef MANGOS
|
||||
#define USING_BOOST
|
||||
#endif
|
||||
|
||||
#ifdef USING_BOOST
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#else
|
||||
#include <ace/RW_Thread_Mutex.h>
|
||||
#include <ace/Guard_T.h>
|
||||
#endif
|
||||
|
||||
#ifdef TRINITY
|
||||
typedef QueryResult ElunaQuery;
|
||||
#define ELUNA_LOG_INFO(...) TC_LOG_INFO("eluna", __VA_ARGS__);
|
||||
@@ -133,25 +121,15 @@ namespace ElunaUtil
|
||||
/*
|
||||
* Usage:
|
||||
* Inherit this class, then when needing lock, use
|
||||
* ReadGuard guard(GetLock());
|
||||
* or
|
||||
* WriteGuard guard(GetLock());
|
||||
* Guard guard(GetLock());
|
||||
*
|
||||
* The lock is automatically released at end of scope
|
||||
*/
|
||||
class RWLockable
|
||||
class Lockable
|
||||
{
|
||||
public:
|
||||
|
||||
#ifdef USING_BOOST
|
||||
typedef boost::shared_mutex LockType;
|
||||
typedef boost::shared_lock<LockType> ReadGuard;
|
||||
typedef boost::unique_lock<LockType> WriteGuard;
|
||||
#else
|
||||
typedef ACE_RW_Thread_Mutex LockType;
|
||||
typedef ACE_Read_Guard<LockType> ReadGuard;
|
||||
typedef ACE_Write_Guard<LockType> WriteGuard;
|
||||
#endif
|
||||
typedef std::mutex LockType;
|
||||
typedef std::lock_guard<LockType> Guard;
|
||||
|
||||
LockType& GetLock() { return _lock; }
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
#include "ElunaCreatureAI.h"
|
||||
#include "ElunaInstanceAI.h"
|
||||
|
||||
// Some dummy includes containing BOOST_VERSION:
|
||||
// ObjectAccessor.h Config.h Log.h
|
||||
#ifndef MANGOS
|
||||
#define USING_BOOST
|
||||
#endif
|
||||
|
||||
#ifdef USING_BOOST
|
||||
#include <boost/filesystem.hpp>
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user