<C++ Server Programming> Troubleshooting - C++ Server and Unreal Engine
Monday, Apr 28, 2025
1. nested threads in C++ Situation I was writing a unit test for my GlobalThreadManager Singleton Class:
TEST_F(ThreadManagerTest, ThreadIdGeneration) { std::vector<std::thread> jobs; std::atomic<int> completion_counter{ 0 }; // Given: 10 threads are generated asynchronously by 10 different threads using GlobalThreadManager, total 100 threads for (int i = 0; i < 10; i++) { jobs.push_back(std::thread([this, &completion_counter]() { for (int j = 0; j < 10; j++) { GlobalThreadManager->Launch([this, &completion_counter]() { std::lock_guard<std::mutex> lock(thread_id_mutex); thread_ids.