Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/msm/back/state_machine.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/msm/back/state_machine.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/msm/back/state_machine.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -266,6 +266,7 @@ template <class StateType,class Enable=int> struct deferred_msg_queue_helper { + void clear(){} }; template <class StateType> struct deferred_msg_queue_helper<StateType, @@ -274,6 +275,10 @@ { public: deferred_msg_queue_helper():m_deferred_events_queue(){} + void clear() + { + m_deferred_events_queue.clear(); + } deferred_events_queue_t m_deferred_events_queue; }; @@ -339,7 +344,7 @@ exit_pt():m_forward(){} // by assignments, we keep our forwarding functor unchanged as our containing SM did not change template <class RHS> - exit_pt(RHS& rhs):m_forward(){} + exit_pt(RHS&):m_forward(){} exit_pt<ExitPoint>& operator= (const exit_pt<ExitPoint>& ) { return *this; @@ -1269,22 +1274,34 @@ m_events_queue.m_events_queue.push_back(f); } template <class EventType> - void enqueue_event_helper(EventType const& evt, ::boost::mpl::true_ const &) + void enqueue_event_helper(EventType const& , ::boost::mpl::true_ const &) { // no queue } void execute_queued_events_helper(::boost::mpl::false_ const &) { - transition_fct to_call = m_events_queue.m_events_queue.front(); - m_events_queue.m_events_queue.pop_front(); - to_call(); + while(!m_events_queue.m_events_queue.empty()) + { + transition_fct to_call = m_events_queue.m_events_queue.front(); + m_events_queue.m_events_queue.pop_front(); + to_call(); + } } void execute_queued_events_helper(::boost::mpl::true_ const &) { // no queue required } - + void execute_single_queued_event_helper(::boost::mpl::false_ const &) + { + transition_fct to_call = m_events_queue.m_events_queue.front(); + m_events_queue.m_events_queue.pop_front(); + to_call(); + } + void execute_single_queued_event_helper(::boost::mpl::true_ const &) + { + // no queue required + } // enqueues an event in the message queue // call execute_queued_events to process all queued events. // Be careful if you do this during event processing, the event will be processed immediately @@ -1300,7 +1317,10 @@ { execute_queued_events_helper(typename is_no_message_queue<library_sm>::type()); } - + void execute_single_queued_event() + { + execute_single_queued_event_helper(typename is_no_message_queue<library_sm>::type()); + } typename events_queue_t::size_type get_message_queue_size() const { return m_events_queue.m_events_queue.size(); @@ -1316,6 +1336,11 @@ return m_events_queue.m_events_queue; } + void clear_deferred_queue() + { + m_deferred_events_queue.clear(); + } + deferred_events_queue_t& get_deferred_queue() { return m_deferred_events_queue.m_deferred_events_queue; @@ -1357,7 +1382,7 @@ >::type ,void >::type - operator()(T& t) const + operator()(T&) const { // no state to serialize } @@ -1694,7 +1719,7 @@ } // the following functions handle pre/post-process handling of a message queue template <class StateType,class EventType> - bool do_pre_msg_queue_helper(EventType const& evt, ::boost::mpl::true_ const &) + bool do_pre_msg_queue_helper(EventType const&, ::boost::mpl::true_ const &) { // no message queue needed return true; @@ -1748,7 +1773,7 @@ this->exception_caught(evt,*this,e); } BOOST_CATCH_END - return HANDLED_FALSE; + return HANDLED_TRUE; } // handling of deferred events // if none is found in the SM, take the following empty main version @@ -2599,6 +2624,9 @@ direct_event_start_helper(this)(incomingEvent,fsm); // handle messages which were generated and blocked in the init calls m_event_processing = false; + // look for deferred events waiting + handle_defer_helper<library_sm> defer_helper(m_deferred_events_queue); + defer_helper.do_post_handle_deferred(HANDLED_TRUE); process_message_queue(this); } template <class Event,class FsmType> @@ -2611,6 +2639,11 @@ (static_cast<Derived*>(this))->on_exit(incomingEvent,fsm); // give the history a chance to handle this (or not). m_history.history_exit(this->m_states); + // history decides what happens with deferred events + if (!m_history.process_deferred_events(incomingEvent)) + { + clear_deferred_queue(); + } } // the IBM and VC<8 compilers seem to have problems with the friend declaration of dispatch_table