本文整理汇总了C++中Map::CanUnload方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::CanUnload方法的具体用法?C++ Map::CanUnload怎么用?C++ Map::CanUnload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::CanUnload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if (!i_timer.Passed())
return;
for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->Update((uint32)i_timer.GetCurrent());
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
{
WorldObject::UpdateHelper helper((*iter));
helper.Update((uint32)i_timer.GetCurrent());
}
// remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin();
while (iter != i_maps.end())
{
Map* pMap = iter->second;
// check if map can be unloaded
if (pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
++iter;
}
i_timer.SetCurrent(0);
}
示例2: Update
void MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if (!i_timer.Passed())
return;
for (auto& i_map : i_maps)
i_map.second->Update((uint32)i_timer.GetCurrent());
for (Transport* m_Transport : m_Transports)
m_Transport->Update((uint32)i_timer.GetCurrent());
// remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin();
while (iter != i_maps.end())
{
Map* pMap = iter->second;
// check if map can be unloaded
if (pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
++iter;
}
i_timer.SetCurrent(0);
}
示例3: Update
void MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if( !i_timer.Passed())
return;
UpdateLoadBalancer(true);
for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
{
if (m_updater.activated())
{
m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
}
else
iter->second->Update((uint32)i_timer.GetCurrent());
}
if (m_updater.activated())
m_updater.wait();
UpdateLoadBalancer(false);
if (m_updater.IsBroken() || m_threadsCountPreferred != m_threadsCount)
{
m_updater.ReActivate(m_threadsCountPreferred);
sLog.outDetail("MapManager::Update map virtual server threads pool reactivated, new threads count is %u", m_threadsCountPreferred);
m_threadsCount = m_threadsCountPreferred;
}
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
{
WorldObject::UpdateHelper helper((*iter));
helper.Update((uint32)i_timer.GetCurrent());
}
//remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin();
while(iter != i_maps.end())
{
Map * pMap = iter->second;
//check if map can be unloaded
if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
++iter;
}
i_timer.SetCurrent(0);
}
示例4: omp_set_num_threads
void
MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if ( !i_timer.Passed() )
return;
MapMapType::iterator iter = i_maps.begin();
std::vector<Map*> update_queue(i_maps.size());
int omp_set_num_threads(sWorld.getConfig(CONFIG_UINT32_NUMTHREADS));
for (uint32 i = 0; iter != i_maps.end(); ++iter, ++i)
update_queue[i] = iter->second;
uint32 i = 0;
#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
for (i = 0; i < i_maps.size(); ++i)
update_queue[i]->Update(i_timer.GetCurrent());
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
(*iter)->Update(i_timer.GetCurrent());
//remove all maps which can be unloaded
iter = i_maps.begin();
while(iter != i_maps.end())
{
Map * pMap = iter->second;
//check if map can be unloaded
if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
++iter;
}
i_timer.SetCurrent(0);
}
示例5: Update
void MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if (!i_timer.Passed())
return;
for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
{
if (m_updater.activated())
m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
else
iter->second->Update((uint32)i_timer.GetCurrent());
}
if (m_updater.activated())
m_updater.wait();
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
(*iter)->Update((uint32)i_timer.GetCurrent());
//remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin();
while(iter != i_maps.end())
{
Map * pMap = iter->second;
//check if map can be unloaded
if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
++iter;
}
i_timer.SetCurrent(0);
}
示例6: Update
void MapManager::Update(uint32 diff)
{
i_timer.Update(diff);
if( !i_timer.Passed())
return;
UpdateLoadBalancer(true);
for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
{
if (m_updater.activated())
{
m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
}
else
iter->second->Update((uint32)i_timer.GetCurrent());
}
if (m_updater.activated())
m_updater.wait();
UpdateLoadBalancer(false);
if (m_updater.IsBroken() || m_threadsCountPreferred != m_threadsCount)
{
m_updater.ReActivate(m_threadsCountPreferred);
sLog.outDetail("MapManager::Update map virtual server threads pool reactivated, new threads count is %u", m_threadsCountPreferred);
m_threadsCount = m_threadsCountPreferred;
}
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
{
WorldObject::UpdateHelper helper((*iter));
helper.Update((uint32)i_timer.GetCurrent());
}
bool b_stat = false;
if (m_statisticInterval < diff)
{
b_stat = true;
m_statisticInterval = sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_INTERVAL);
}
else
m_statisticInterval -= diff;
//remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin();
while(iter != i_maps.end())
{
Map * pMap = iter->second;
//check if map can be unloaded
if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
{
pMap->UnloadAll(true);
delete pMap;
i_maps.erase(iter++);
}
else
{
++iter;
if (sWorld.getConfig(CONFIG_BOOL_VMSS_STATISTIC_ENABLE) && b_stat)
UpdateStatisticForMap(pMap);
}
}
if (sWorld.getConfig(CONFIG_BOOL_VMSS_STATISTIC_ENABLE) && b_stat)
{
if (m_statMaps.size() != sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_THREADSCOUNT))
m_statMaps.resize(sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_THREADSCOUNT), (Map*)NULL);
for (std::vector<Map*>::iterator i = m_statMaps.begin(); i != m_statMaps.end(); ++i)
{
Map* map = *i;
if (map)
map->PrintStatistic();
}
m_statMaps.clear();
}
i_timer.SetCurrent(0);
}