libs/wampcc/wamp_session.cc
/* Implement the actual state transition to closed. This must only be called via
 * the EV thread. */
Implement the actual state transition to closed. This must only be called via
the EV thread.
Implement the actual state transition to closed . This must only be called via the EV thread .
void wamp_session::transition_to_closed()
{
  assert(m_kernel->get_event_loop()->this_thread_is_ev() == true);
  {
    std::lock_guard<std::mutex> guard(m_state_lock);
    if (m_state == state::closed)
      return;
    else
      m_state = state::closed;
  }
  try {
    if (m_notify_state_change_fn)
      m_notify_state_change_fn(*this, false);
  }
  catch (...) {
  }
  m_has_closed.set_value();
}
void wamp_session :: transition_to_closed ( ) { assert ( m_kernel -> get_event_loop ( ) -> this_thread_is_ev ( ) == true ) ; { std :: lock_guard < std :: mutex > guard ( m_state_lock ) ; if ( m_state == state :: closed ) return ; else m_state = state :: closed ; } try { if ( m_notify_state_change_fn ) m_notify_state_change_fn ( * this , false ) ; } catch ( ... ) { } m_has_closed . set_value ( ) ; }
Implement the actual state transition to closed.
Implement the actual state transition to closed .
/* EV thread */ // Make final check of session state to ensure that user callback is only ever // called once. Even though this is also protected when the event is initially // dispatched, later code modification might attempt to push additional close // callbacks. // The order of invoking the user callback and setting the has-closed promise // is deliberately chosen here.  The promise 'set_value' must be the later // action, so that user can rely on it to indicate when all wamp_session // callbacks into user code have been complete. But it also implies that // during the user callback, the has-closed future cannot be waited on; that // would be a programming error. /* ignore */