Program Listing for File SimCluster.hpp
↰ Return to documentation for file (src/core/SimCluster.hpp)
#ifndef SIMCLUSTER_HPP
#define SIMCLUSTER_HPP
#include "../io/OutputManager.hpp"
#include "../io/SimControls.hpp"
#include <atomic>
#include <memory>
namespace core
{
class SimCluster
{
public:
SimCluster(const io::SimControls& simControls,
std::unique_ptr<io::OutputManager> outputManager, bool restart = false);
// Disallow copying and moving: this object owns the output
// manager exclusively, so duplicating or relocating it makes
// no sense
SimCluster(const SimCluster&) = delete;
auto operator=(const SimCluster&) -> SimCluster& = delete;
SimCluster(SimCluster&&) = delete;
auto operator=(SimCluster&&) -> SimCluster& = delete;
~SimCluster() = default;
static constexpr int sigtermExitCode = 143;
auto run() -> int;
[[nodiscard]] auto trialsCompleted() const -> unsigned long
{
return trialsCompleted_.load(std::memory_order_relaxed);
}
private:
void runTrial(unsigned long trialNum);
const io::SimControls& simControls_;
std::unique_ptr<io::OutputManager> outputManager_;
std::atomic<unsigned long> trialsCompleted_{0};
bool restart_ = false;
};
} // namespace core
#endif // SIMCLUSTER_HPP