Verbessere die CMake-Konfiguration zur Unterstützung von C++23, indem die Compiler-Auswahl dynamisch auf GCC 15 oder 13 basiert. Optimiere die Compiler-Flags für Leistung. In der Datenbankabfrage und im DirectorWorker werden konstante Referenzen und string_view verwendet, um die Leistung zu steigern. Reserviere Speicher für Vektoren in main.cpp zur Effizienzsteigerung.
This commit is contained in:
committed by
Torsten (PC)
parent
1f43df6d41
commit
4bafc3a61c
21
src/main.cpp
21
src/main.cpp
@@ -44,16 +44,19 @@ int main() {
|
||||
int websocketPort = std::stoi(config.get("WEBSOCKET_PORT"));
|
||||
MessageBroker broker;
|
||||
WebSocketServer websocketServer(websocketPort, pool, broker);
|
||||
// Use C++23 features for better performance
|
||||
std::vector<std::unique_ptr<Worker>> workers;
|
||||
workers.push_back(std::make_unique<CharacterCreationWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<ProduceWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<StockageManager>(pool, broker));
|
||||
workers.push_back(std::make_unique<DirectorWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<ValueRecalculationWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<UserCharacterWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<HouseWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<PoliticsWorker>(pool, broker));
|
||||
workers.push_back(std::make_unique<UndergroundWorker>(pool, broker));
|
||||
workers.reserve(9); // Pre-allocate for better performance
|
||||
|
||||
workers.emplace_back(std::make_unique<CharacterCreationWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<ProduceWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<StockageManager>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<DirectorWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<ValueRecalculationWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<UserCharacterWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<HouseWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<PoliticsWorker>(pool, broker));
|
||||
workers.emplace_back(std::make_unique<UndergroundWorker>(pool, broker));
|
||||
websocketServer.setWorkers(workers);
|
||||
|
||||
broker.start();
|
||||
|
||||
Reference in New Issue
Block a user