Program Listing for File mt_fsm.hpp
↰ Return to documentation for file (rcppsw/multithread/mt_fsm.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include <memory>
#include <mutex>
#include <string>
#include "rcppsw/patterns/fsm/base_fsm.hpp"
#include "rcppsw/rcppsw.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace rcppsw::multithread {
namespace sm = patterns::fsm;
/*******************************************************************************
* Class Definitions
******************************************************************************/
class mt_fsm : public rpfsm::base_fsm {
public:
explicit mt_fsm(uint8_t max_states, uint8_t initial_state = 0)
: base_fsm(max_states, initial_state) {}
~mt_fsm(void) override = default;
void init(void) override;
protected:
void external_event(uint8_t new_state,
std::unique_ptr<sm::event_data> data) override;
private:
/* clang-format on */
std::mutex m_mutex{};
/* clang-format off */
};
} /* namespace rcppsw::multithread */