Program Listing for File concurrence.hpp
↰ Return to documentation for file (include/yasmin/concurrence.hpp)
// Copyright (C) 2025 Georgia Tech Research Institute
// Supported by USDA-NIFA CSIAPP Grant. No. 2023-70442-39232
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef YASMIN__CONCURRENCE_HPP_
#define YASMIN__CONCURRENCE_HPP_
#include <atomic>
#include <iostream>
#include <mutex>
#include <string>
#include <thread>
#ifdef __GNUG__ // If using GCC/G++
#include <cxxabi.h> // For abi::__cxa_demangle
#endif
#include "yasmin/blackboard.hpp"
#include "yasmin/state.hpp"
#include "yasmin/types.hpp"
namespace yasmin {
class Concurrence : public State {
protected:
const StateMap states;
const std::string default_outcome;
OutcomeMap outcome_map;
StateOutcomeMap intermediate_outcome_map;
Outcomes possible_outcomes;
private:
std::mutex intermediate_outcome_mutex;
static Outcomes
generate_possible_outcomes(const OutcomeMap &outcome_map,
const std::string &default_outcome);
public:
YASMIN_PTR_ALIASES(Concurrence)
Concurrence(const StateMap &states, const std::string &default_outcome,
const OutcomeMap &outcome_map);
std::string execute(Blackboard::SharedPtr blackboard) override;
void cancel_state() override;
const StateMap &get_states() const noexcept;
const OutcomeMap &get_outcome_map() const noexcept;
const std::string &get_default_outcome() const noexcept;
std::string to_string() const override;
};
} // namespace yasmin
#endif // YASMIN__CONCURRENCE_HPP_