TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
callbacks.cpp
1// Copyright (c) 2013-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
20#include "./callbacks.hpp"
21#include "./signal_handler.hpp"
22
23#include <chrono>
24#include <functional>
25
26namespace triqs::utility {
27
28 std::function<bool()> clock_callback(int time_in_seconds) {
30 if (time_in_seconds <= 0) return []() { return false; };
31
32 auto end_time = std::chrono::system_clock::now() + std::chrono::seconds(time_in_seconds);
33 return [end_time]() { return (std::chrono::system_clock::now() > end_time); };
34 }
35
36} // namespace triqs::utility
Callbacks used by the Monte Carlo framework.
std::function< bool()> clock_callback(int time_in_seconds)
Build a callback that returns true once a given time in seconds has elapsed since its creation.
Definition callbacks.cpp:28
void start()
Install the TRIQS signal handler.
Provides a signal handler for the TRIQS library.