mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[9245] Remove CellLock class and all cell-level thread locking.
* It was wasting CPU power as cell-level locking is not needed. * Future multithreading will be on map-level. * CellLock was just a 'proxy' between Cell and CellPair and in some cases carried redundant data. * Some minor cleanup in Cell::Visit/Map::Visit.
This commit is contained in:
parent
39b7636094
commit
0ff9250de2
19 changed files with 104 additions and 209 deletions
|
|
@ -47,27 +47,6 @@ struct ScriptInfo;
|
|||
struct ScriptAction;
|
||||
class BattleGround;
|
||||
|
||||
|
||||
typedef ACE_RW_Thread_Mutex GridRWLock;
|
||||
|
||||
template<class MUTEX, class LOCK_TYPE>
|
||||
struct RGuard
|
||||
{
|
||||
RGuard(MUTEX &l) : i_lock(l.getReadLock()) {}
|
||||
MaNGOS::GeneralLock<LOCK_TYPE> i_lock;
|
||||
};
|
||||
|
||||
template<class MUTEX, class LOCK_TYPE>
|
||||
struct WGuard
|
||||
{
|
||||
WGuard(MUTEX &l) : i_lock(l.getWriteLock()) {}
|
||||
MaNGOS::GeneralLock<LOCK_TYPE> i_lock;
|
||||
};
|
||||
|
||||
typedef RGuard<GridRWLock, ACE_Thread_Mutex> GridReadGuard;
|
||||
typedef WGuard<GridRWLock, ACE_Thread_Mutex> GridWriteGuard;
|
||||
typedef MaNGOS::SingleThreaded<GridRWLock>::Lock NullGuard;
|
||||
|
||||
//******************************************
|
||||
// Map file format defines
|
||||
//******************************************
|
||||
|
|
@ -280,7 +259,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
|||
void PlayerRelocation(Player *, float x, float y, float z, float angl);
|
||||
void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation);
|
||||
|
||||
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &visitor);
|
||||
template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor);
|
||||
|
||||
bool IsRemovalGrid(float x, float y) const
|
||||
{
|
||||
|
|
@ -523,9 +502,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
|||
//InstanceMaps and BattleGroundMaps...
|
||||
Map* m_parentMap;
|
||||
|
||||
typedef GridReadGuard ReadGuard;
|
||||
typedef GridWriteGuard WriteGuard;
|
||||
|
||||
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
GridMap *GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
|
||||
|
|
@ -638,19 +614,18 @@ Map::CalculateGridMask(const uint32 &y) const
|
|||
}
|
||||
*/
|
||||
|
||||
template<class LOCK_TYPE, class T, class CONTAINER>
|
||||
template<class T, class CONTAINER>
|
||||
inline void
|
||||
Map::Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &visitor)
|
||||
Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
|
||||
{
|
||||
const uint32 x = cell->GridX();
|
||||
const uint32 y = cell->GridY();
|
||||
const uint32 cell_x = cell->CellX();
|
||||
const uint32 cell_y = cell->CellY();
|
||||
const uint32 x = cell.GridX();
|
||||
const uint32 y = cell.GridY();
|
||||
const uint32 cell_x = cell.CellX();
|
||||
const uint32 cell_y = cell.CellY();
|
||||
|
||||
if( !cell->NoCreate() || loaded(GridPair(x,y)) )
|
||||
if( !cell.NoCreate() || loaded(GridPair(x,y)) )
|
||||
{
|
||||
EnsureGridLoaded(cell);
|
||||
//LOCK_TYPE guard(i_info[x][y]->i_lock);
|
||||
getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue