Skip to content
Snippets Groups Projects
Commit c60db6f7 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ISimulation::runSingleSimulation: all-in-one thread works

parent 088d8e2b
No related branches found
No related tags found
1 merge request!1276rm ISimulation::compute
......@@ -25,8 +25,8 @@
#include "Sim/Computation/IComputation.h"
#include <gsl/gsl_errno.h>
#include <iostream>
#include <thread>
#include <mutex>
#include <thread>
namespace {
......@@ -233,16 +233,17 @@ void ISimulation::runSingleSimulation(const ReSample& re_sample, size_t batch_st
const size_t thread_size = batchSize(n_threads, i_thread, batch_size);
if (thread_size == 0)
break;
threads.emplace_back(new std::thread([&]() {
mutex.lock();
const auto& c = createComputation(re_sample, thread_start, thread_size);
mutex.unlock();
c->compute(); // <---- here most work is done (threaded case)!
mutex.lock();
if (!c->isCompleted())
failure_messages.push_back(c->errorMessage());
mutex.unlock();
}));
threads.emplace_back(new std::thread(
[this, &re_sample, &failure_messages, &mutex, thread_start, thread_size]() {
mutex.lock();
const auto& c = createComputation(re_sample, thread_start, thread_size);
mutex.unlock();
c->compute(); // <---- here most work is done (threaded case)!
mutex.lock();
if (!c->isCompleted())
failure_messages.push_back(c->errorMessage());
mutex.unlock();
}));
}
// Wait for threads to complete.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment