mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 22:03:43 +01:00
callback: move to std::chrono instead of boost
- and rm boost::function clashing with std:function (detected by new clang).
This commit is contained in:
parent
72b1f081ac
commit
02b6cedd14
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
|
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
|
||||||
@ -22,6 +21,29 @@
|
|||||||
|
|
||||||
#include "callbacks.hpp"
|
#include "callbacks.hpp"
|
||||||
#include "signal_handler.hpp"
|
#include "signal_handler.hpp"
|
||||||
|
|
||||||
|
// switch to std. Remove old boost code when ok on several compilers
|
||||||
|
#ifndef TRIQS_USE_BOOST_CHRONO
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace triqs {
|
||||||
|
namespace utility {
|
||||||
|
|
||||||
|
std::function<bool()> clock_callback(int time_in_seconds) {
|
||||||
|
if (time_in_seconds <= 0)
|
||||||
|
return []() { return (!triqs::signal_handler().empty()); };
|
||||||
|
|
||||||
|
// auto end_time = boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(time_in_seconds);
|
||||||
|
// return [end_time]() { return (!triqs::signal_handler().empty()) || boost::posix_time::second_clock::local_time() > end_time
|
||||||
|
|
||||||
|
auto end_time = std::chrono::system_clock::now() + std::chrono::seconds(time_in_seconds);
|
||||||
|
return [end_time]() { return (!triqs::signal_handler().empty()) || (std::chrono::system_clock::now() > end_time); };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
@ -34,12 +56,12 @@ namespace triqs {
|
|||||||
|
|
||||||
bool false_callback_impl() { return (!triqs::signal_handler().empty()); }
|
bool false_callback_impl() { return (!triqs::signal_handler().empty()); }
|
||||||
|
|
||||||
boost::function<bool ()> clock_callback(int time_in_seconds) {
|
std::function<bool()> clock_callback(int time_in_seconds) {
|
||||||
return (time_in_seconds>0 ?
|
return (time_in_seconds > 0 ? boost::bind(&clock_callback_impl, boost::posix_time::second_clock::local_time() +
|
||||||
boost::bind(&clock_callback_impl, boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(time_in_seconds)) :
|
boost::posix_time::seconds(time_in_seconds))
|
||||||
boost::function<bool ()> (&false_callback_impl));
|
: std::function<bool()>(&false_callback_impl));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#ifndef TRIQS_TOOLS_MC_CALLBACKS_H
|
#ifndef TRIQS_TOOLS_MC_CALLBACKS_H
|
||||||
#define TRIQS_TOOLS_MC_CALLBACKS_H
|
#define TRIQS_TOOLS_MC_CALLBACKS_H
|
||||||
#include <triqs/utility/first_include.hpp>
|
#include <triqs/utility/first_include.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <functional>
|
||||||
|
|
||||||
namespace triqs { namespace utility {
|
namespace triqs { namespace utility {
|
||||||
|
|
||||||
boost::function<bool ()> clock_callback(int time_in_seconds);
|
std::function<bool ()> clock_callback(int time_in_seconds);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user