Skip to content
Snippets Groups Projects
Commit 322a22f0 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Replaced boost threads and mutexes with std threads and mutexes (c++11)

parent 71b5bd27
No related branches found
No related tags found
No related merge requests found
...@@ -26,11 +26,6 @@ ...@@ -26,11 +26,6 @@
#include "Histogram2D.h" #include "Histogram2D.h"
#include "Macros.h" #include "Macros.h"
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
#include <boost/thread.hpp>
GCC_DIAG_ON(strict-aliasing)
GCC_DIAG_ON(unused-parameter)
#include <gsl/gsl_errno.h> #include <gsl/gsl_errno.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "Simulation.h" #include "Simulation.h"
#include "MultiLayer.h" #include "MultiLayer.h"
#include "LayerInterface.h" #include "LayerInterface.h"
#include <boost/thread.hpp> #include <mutex>
ProgressHandler::ProgressHandler() ProgressHandler::ProgressHandler()
...@@ -44,8 +44,8 @@ void ProgressHandler::reset() ...@@ -44,8 +44,8 @@ void ProgressHandler::reset()
//! them to stop calculations. //! them to stop calculations.
bool ProgressHandler::update(int n) bool ProgressHandler::update(int n)
{ {
static boost::mutex single_mutex; static std::mutex single_mutex;
boost::unique_lock<boost::mutex> single_lock( single_mutex ); std::unique_lock<std::mutex> single_lock( single_mutex );
// this flag is to inform Simulation that GUI wants it to be terminated // this flag is to inform Simulation that GUI wants it to be terminated
bool continue_calculations(true); bool continue_calculations(true);
......
...@@ -23,11 +23,9 @@ ...@@ -23,11 +23,9 @@
#include "BornAgainNamespace.h" #include "BornAgainNamespace.h"
#include "ProgressHandlerDWBA.h" #include "ProgressHandlerDWBA.h"
#include "OMPISimulation.h" #include "OMPISimulation.h"
#include <thread>
#include "Macros.h" #include "Macros.h"
GCC_DIAG_OFF(strict-aliasing);
#include <boost/thread.hpp>
GCC_DIAG_ON(strict-aliasing);
#include <gsl/gsl_errno.h> #include <gsl/gsl_errno.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
...@@ -231,7 +229,7 @@ void Simulation::runSingleSimulation() ...@@ -231,7 +229,7 @@ void Simulation::runSingleSimulation()
// Multithreading. // Multithreading.
if (m_thread_info.n_threads == 0) { if (m_thread_info.n_threads == 0) {
// Take optimal number of threads from the hardware. // Take optimal number of threads from the hardware.
m_thread_info.n_threads = (int)boost::thread::hardware_concurrency(); m_thread_info.n_threads = (int)std::thread::hardware_concurrency();
msglog(MSG::DEBUG) << "Simulation::runSimulation() -> Info. Number of threads " msglog(MSG::DEBUG) << "Simulation::runSimulation() -> Info. Number of threads "
<< m_thread_info.n_threads << " (taken from hardware concurrency)" << m_thread_info.n_threads << " (taken from hardware concurrency)"
<< ", n_batches = " << m_thread_info.n_batches << ", n_batches = " << m_thread_info.n_batches
...@@ -242,7 +240,7 @@ void Simulation::runSingleSimulation() ...@@ -242,7 +240,7 @@ void Simulation::runSingleSimulation()
<< ", n_batches = " << m_thread_info.n_batches << ", n_batches = " << m_thread_info.n_batches
<< ", current_batch = " << m_thread_info.current_batch; << ", current_batch = " << m_thread_info.current_batch;
} }
std::vector<boost::thread *> threads; std::vector<std::thread *> threads;
std::vector<DWBASimulation *> simulations; std::vector<DWBASimulation *> simulations;
// Initialize n simulations. // Initialize n simulations.
...@@ -269,7 +267,7 @@ void Simulation::runSingleSimulation() ...@@ -269,7 +267,7 @@ void Simulation::runSingleSimulation()
// Run simulations in n threads. // Run simulations in n threads.
for (std::vector<DWBASimulation *>::iterator it = simulations.begin(); for (std::vector<DWBASimulation *>::iterator it = simulations.begin();
it != simulations.end(); ++it) { it != simulations.end(); ++it) {
threads.push_back(new boost::thread(boost::bind(&DWBASimulation::run, *it))); threads.push_back(new std::thread(boost::bind(&DWBASimulation::run, *it)));
} }
// Wait for threads to complete. // Wait for threads to complete.
......
...@@ -19,12 +19,8 @@ ...@@ -19,12 +19,8 @@
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
#include <typeinfo> #include <typeinfo>
#include <mutex>
#include "Macros.h" #include "Macros.h"
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
#include <boost/thread.hpp>
GCC_DIAG_ON(strict-aliasing)
GCC_DIAG_ON(unused-parameter)
//! @class ISingleton //! @class ISingleton
//! @ingroup tools_internal //! @ingroup tools_internal
...@@ -36,8 +32,8 @@ class ISingleton ...@@ -36,8 +32,8 @@ class ISingleton
public: public:
static T& instance() static T& instance()
{ {
static boost::mutex single_mutex; static std::mutex single_mutex;
boost::unique_lock<boost::mutex> single_lock( single_mutex ); std::unique_lock<std::mutex> single_lock( single_mutex );
if( !m_instance) { if( !m_instance) {
if( m_destroyed ) { if( m_destroyed ) {
onDeadReference(); onDeadReference();
......
...@@ -24,13 +24,9 @@ ...@@ -24,13 +24,9 @@
#include <boost/date_time/local_time_adjustor.hpp> #include <boost/date_time/local_time_adjustor.hpp>
#include <boost/date_time/c_local_time_adjustor.hpp> #include <boost/date_time/c_local_time_adjustor.hpp>
#include <string> #include <string>
#include <thread>
#include "Macros.h" #include "Macros.h"
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
#include <boost/thread.hpp>
GCC_DIAG_ON(strict-aliasing)
GCC_DIAG_ON(unused-parameter)
#ifdef DEBUG_FPE #ifdef DEBUG_FPE
...@@ -144,7 +140,7 @@ std::string Utils::String::getScientificDoubleString(double value, size_t precis ...@@ -144,7 +140,7 @@ std::string Utils::String::getScientificDoubleString(double value, size_t precis
int Utils::System::getThreadHardwareConcurrency() int Utils::System::getThreadHardwareConcurrency()
{ {
return (int)boost::thread::hardware_concurrency(); return std::thread::hardware_concurrency();
} }
std::string Utils::System::getCurrentDateAndTime() std::string Utils::System::getCurrentDateAndTime()
......
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