Skip to content

Commit

Permalink
Disable multi-threading
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Feb 25, 2022
1 parent 7061c55 commit 6cb1354
Showing 1 changed file with 2 additions and 53 deletions.
55 changes: 2 additions & 53 deletions src/SimulationRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ SimulationRunner::SimulationRunner(const sdf::World *_world,
//////////////////////////////////////////////////
SimulationRunner::~SimulationRunner()
{
this->StopWorkerThreads();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -503,56 +502,11 @@ void SimulationRunner::ProcessSystemQueue()
std::lock_guard<std::mutex> lock(this->pendingSystemsMutex);
auto pending = this->pendingSystems.size();

if (pending > 0)
{
// If additional systems are to be added, stop the existing threads.
this->StopWorkerThreads();
}

for (const auto &system : this->pendingSystems)
{
this->AddSystemToRunner(system);
}
this->pendingSystems.clear();

// If additional systems were added, recreate the worker threads.
if (pending > 0)
{
igndbg << "Creating PostUpdate worker threads: "
<< this->systemsPostupdate.size() + 1 << std::endl;

this->postUpdateStartBarrier =
std::make_unique<Barrier>(this->systemsPostupdate.size() + 1u);
this->postUpdateStopBarrier =
std::make_unique<Barrier>(this->systemsPostupdate.size() + 1u);

this->postUpdateThreadsRunning = true;
int id = 0;

for (auto &system : this->systemsPostupdate)
{
igndbg << "Creating postupdate worker thread (" << id << ")" << std::endl;

this->postUpdateThreads.push_back(std::thread([&, id]()
{
std::stringstream ss;
ss << "PostUpdateThread: " << id;
IGN_PROFILE_THREAD_NAME(ss.str().c_str());
while (this->postUpdateThreadsRunning)
{
this->postUpdateStartBarrier->Wait();
if (this->postUpdateThreadsRunning)
{
system->PostUpdate(this->currentInfo, this->entityCompMgr);
}
this->postUpdateStopBarrier->Wait();
}
igndbg << "Exiting postupdate worker thread ("
<< id << ")" << std::endl;
}));
id++;
}
}
}

/////////////////////////////////////////////////
Expand All @@ -579,13 +533,8 @@ void SimulationRunner::UpdateSystems()

{
IGN_PROFILE("PostUpdate");
// If no systems implementing PostUpdate have been added, then
// the barriers will be uninitialized, so guard against that condition.
if (this->postUpdateStartBarrier && this->postUpdateStopBarrier)
{
this->postUpdateStartBarrier->Wait();
this->postUpdateStopBarrier->Wait();
}
for (auto& system : this->systemsPostupdate)
system->PostUpdate(this->currentInfo, this->entityCompMgr);
}
}

Expand Down

0 comments on commit 6cb1354

Please sign in to comment.