reduce MSpawnList writelock from outside the for loop
This commit is contained in:
parent
9e1f77e28e
commit
cb5371793e
@ -1516,7 +1516,6 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
|||||||
std::vector<std::pair<Spawn*,int32>> to_keep;
|
std::vector<std::pair<Spawn*,int32>> to_keep;
|
||||||
to_keep.reserve(to_process.size());
|
to_keep.reserve(to_process.size());
|
||||||
|
|
||||||
MSpawnList.writelock(__FUNCTION__, __LINE__);
|
|
||||||
int32 current_time = Timer::GetCurrentTime2();
|
int32 current_time = Timer::GetCurrentTime2();
|
||||||
for (auto &entry : to_process) {
|
for (auto &entry : to_process) {
|
||||||
Spawn* spawn = entry.first;
|
Spawn* spawn = entry.first;
|
||||||
@ -1535,8 +1534,9 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
|||||||
}
|
}
|
||||||
MPendingSpawnRemoval.releasereadlock(__FUNCTION__, __LINE__);
|
MPendingSpawnRemoval.releasereadlock(__FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
MSpawnList.writelock(__FUNCTION__, __LINE__);
|
||||||
lua_interface->SetLuaUserDataStale(spawn);
|
lua_interface->SetLuaUserDataStale(spawn);
|
||||||
|
|
||||||
if (spellProcess) {
|
if (spellProcess) {
|
||||||
spellProcess->RemoveCaster(spawn, true);
|
spellProcess->RemoveCaster(spawn, true);
|
||||||
}
|
}
|
||||||
@ -1572,8 +1572,8 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
|||||||
housing_spawn_map.erase(spawn->GetID());
|
housing_spawn_map.erase(spawn->GetID());
|
||||||
}
|
}
|
||||||
safe_delete(spawn);
|
safe_delete(spawn);
|
||||||
|
MSpawnList.releasewritelock(__FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
MSpawnList.releasewritelock(__FUNCTION__, __LINE__);
|
|
||||||
|
|
||||||
// Add all the kept entries
|
// Add all the kept entries
|
||||||
if (!to_keep.empty()) {
|
if (!to_keep.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user