void MapBuilder::buildAllMaps(int threads) { std::vector<BuilderThread*> _threads; BuilderThreadPool* pool = threads > 0 ? new BuilderThreadPool() : NULL; for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapID = it->first; if (!shouldSkipMap(mapID)) { if (threads > 0) pool->Enqueue(new MapBuildRequest(mapID)); else buildMap(mapID); } } for (int i = 0; i < threads; ++i) _threads.push_back(new BuilderThread(this, pool->Queue())); // Free memory for (std::vector<BuilderThread*>::iterator _th = _threads.begin(); _th != _threads.end(); ++_th) { (*_th)->wait(); delete *_th; } delete pool; }
void MapBuilder::buildAllMaps() { for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { int mapID = (*it).first; if (!shouldSkipMap(mapID)) { buildMap(mapID); } } }
void MapBuilder::buildAllMaps() { for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapID = (*it).first; if (!shouldSkipMap(mapID,m_skipContinents,m_skipJunkMaps,m_skipBattlegrounds)) { buildMap(mapID, false); } } if (activated()) { Tile_Message_Block *finish_mb = new Tile_Message_Block(NULL); finish_mb->msg_type(ACE_Message_Block::MB_HANGUP); m_threadPool->putq(finish_mb); m_threadPool->wait(); } }
void MapBuilder::buildAllMaps(int threads) { for (int i = 0; i < threads; ++i) { _workerThreads.push_back(std::thread(&MapBuilder::WorkerThread, this)); } m_tiles.sort([](MapTiles a, MapTiles b) { return a.m_tiles->size() > b.m_tiles->size(); }); for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapId = it->m_mapId; if (!shouldSkipMap(mapId)) { if (threads > 0) _queue.Push(mapId); else buildMap(mapId); } } while (!_queue.Empty()) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } _cancelationToken = true; _queue.Cancel(); for (auto& thread : _workerThreads) { thread.join(); } }