Exemplo n.º 1
0
void
agent_t::so_bind_to_dispatcher(
	event_queue_t & queue )
{
	std::lock_guard< default_rw_spinlock_t > queue_lock{ m_event_queue_lock };

	// Cooperation usage counter should be incremented.
	// It will be decremented during final agent event execution.
	coop_t::increment_usage_count( *m_agent_coop );

	so_5::details::invoke_noexcept_code( [&] {
			// A starting demand must be sent first.
			queue.push(
					execution_demand_t(
							this,
							message_limit::control_block_t::none(),
							0,
							typeid(void),
							message_ref_t(),
							&agent_t::demand_handler_on_start ) );
			
			// Only then pointer to the queue could be stored.
			m_event_queue = &queue;
		} );
}
Exemplo n.º 2
0
		//! Initializing constructor for the case when MSG is a message type.
		transformed_message_t(
			//! Message box to which transformed message to be sent.
			mbox_t mbox,
			//! New message instance.
			std::unique_ptr< MSG > msg )
			:	m_mbox( std::move( mbox ) )
			{
				ensure_message_with_actual_data( msg.get() );

				m_message = message_ref_t( msg.release() );
			}