1 #ifndef FACT_StateMachineAsio 2 #define FACT_StateMachineAsio 4 #include <boost/asio.hpp> 5 #include <boost/bind.hpp> 8 class StateMachineAsio :
public T,
public boost::asio::io_service,
public boost::asio::io_service::work
15 if (error && error!=boost::asio::error::basic_errors::operation_aborted)
18 fTrigger.expires_from_now(boost::posix_time::microseconds(10000));
20 this, boost::asio::placeholders::error));
22 if (!T::HandleNewState(
Execute(), 0,
"by HandleTrigger()"))
28 const auto ptr = T::PopEvent();
29 if (!T::HandleEvent(*ptr))
43 fTrigger.expires_from_now(boost::posix_time::microseconds(0));
45 this, boost::asio::placeholders::error));
53 if (!T::HandleNewState(
Execute(), 0,
"by Run()"))
60 if (T::fExitRequested==-1)
62 T::Fatal(
"Fatal Error occured... shutting down.");
68 const int exitcode = T::fExitRequested-1;
69 T::fExitRequested = 0;
76 T(out, server),
boost::asio::io_service::work(static_cast<
boost::asio::io_service&>(*this)),
77 fTrigger(static_cast<
boost::asio::io_service&>(*this))
Mainloop running, state machine in operation.
boost::asio::deadline_timer fTrigger
void HandleTrigger(const boost::system::error_code &error)
Mainloop not running, state machine stopped.
StateMachineAsio(std::ostream &out, const std::string &server)
Concerete implementation of an EventImp stroring name, format, data and time.
void PushEvent(Event *cmd)