STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Concurrency::_Order_node_base< _Type > Class Template Referenceabstract

Base class for Helper node used in multi-type join and choice blocks Order node is a single-target, single-source ordered propagator block The main property of an order node is that it accepts a message of _Type and outputs a message of int, with some unique assigned index number. More...

#include <agents.h>

Inheritance diagram for Concurrency::_Order_node_base< _Type >:
Concurrency::propagator_block< single_link_registry< ITarget< size_t > >, multi_link_registry< ISource< _Type > > > Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType > Concurrency::ITarget< multi_link_registry< ISource< _Type > >::type::source_type > Concurrency::ISource< single_link_registry< ITarget< size_t > >::type::type > Concurrency::_Greedy_node< _Type > Concurrency::_Non_greedy_node< _Type > Concurrency::_Reserving_node< _Type >

Public Member Functions

 _Order_node_base ()
 Constructs a _Order_node_base within the default scheduler, and places it on any schedule group of the scheduler's choosing. More...
 
 ~_Order_node_base ()
 Cleans up any resources that may have been created by the _Order_node. More...
 
bool has_value () const
 Checks whether this block has been initialized yet. More...
 
_Type const & value ()
 Gets a reference to the current payload of the message being stored. More...
 
virtual void _Reset ()=0
 Resets the _Order_node_base and prepares it for the next propagation More...
 
virtual bool reserve_message (runtime_object_identity)
 Reserves a message previously offered by the source. More...
 
virtual message< size_t > * consume_message (runtime_object_identity)
 Consumes a message previously offered by the source and reserved by the target, transferring ownership to the caller. More...
 
virtual void release_message (runtime_object_identity)
 Releases a previous message reservation. More...
 
- Public Member Functions inherited from Concurrency::propagator_block< single_link_registry< ITarget< size_t > >, multi_link_registry< ISource< _Type > > >
 propagator_block ()
 Constructs a propagator_block object. More...
 
virtual ~propagator_block ()
 Destroys a propagator_block object. More...
 
virtual message_status propagate (_Inout_opt_ message< _Source_type > *_PMessage, _Inout_opt_ ISource< _Source_type > *_PSource)
 Asynchronously passes a message from a source block to this target block. More...
 
virtual message_status send (_Inout_ message< _Source_type > *_PMessage, _Inout_ ISource< _Source_type > *_PSource)
 Synchronously initiates a message to this block. Called by an ISource block. When this function completes, the message will already have propagated into the block. More...
 
- Public Member Functions inherited from Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >
 source_block ()
 Constructs a source_block object. More...
 
virtual ~source_block ()
 Destroys the source_block object. More...
 
virtual void link_target (_Inout_ ITarget< _Target_type > *_PTarget)
 Links a target block to this source_block object. More...
 
virtual void unlink_target (_Inout_ ITarget< _Target_type > *_PTarget)
 Unlinks a target block from this source_block object. More...
 
virtual void unlink_targets ()
 Unlinks all target blocks from this source_block object. More...
 
virtual message< _Target_type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< _Target_type > *_PTarget)
 Accepts a message that was offered by this source_block object, transferring ownership to the caller. More...
 
virtual bool reserve (runtime_object_identity _MsgId, _Inout_ ITarget< _Target_type > *_PTarget)
 Reserves a message previously offered by this source_block object. More...
 
virtual message< _Target_type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< _Target_type > *_PTarget)
 Consumes a message previously offered by this source_block object and successfully reserved by the target, transferring ownership to the caller. More...
 
virtual void release (runtime_object_identity _MsgId, _Inout_ ITarget< _Target_type > *_PTarget)
 Releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< _Target_type > *)
 Acquires a reference count on this source_block object, to prevent deletion. More...
 
virtual void release_ref (_Inout_ ITarget< _Target_type > *_PTarget)
 Releases a reference count on this source_block object. More...
 
- Public Member Functions inherited from Concurrency::ISource< single_link_registry< ITarget< size_t > >::type::type >
virtual ~ISource ()
 Destroys the ISource object. More...
 
virtual void link_target (_Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, links a target block to this ISource block. More...
 
virtual void unlink_target (_Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, unlinks a target block from this ISource block, if found to be previously linked. More...
 
virtual message< single_link_registry< ITarget< size_t > >::type::type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, accepts a message that was offered by this ISource block, transferring ownership to the caller. More...
 
virtual bool reserve (runtime_object_identity _MsgId, _Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, reserves a message previously offered by this ISource block. More...
 
virtual message< single_link_registry< ITarget< size_t > >::type::type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, consumes a message previously offered by this ISource block and successfully reserved by the target, transferring ownership to the caller. More...
 
virtual void release (runtime_object_identity _MsgId, _Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, acquires a reference count on this ISource block, to prevent deletion. More...
 
virtual void release_ref (_Inout_ ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PTarget)=0
 When overridden in a derived class, releases a reference count on this ISource block. More...
 
- Public Member Functions inherited from Concurrency::ITarget< multi_link_registry< ISource< _Type > >::type::source_type >
virtual ~ITarget ()
 Destroys the ITarget object. More...
 
virtual message_status propagate (_Inout_opt_ message< multi_link_registry< ISource< _Type > >::type::source_type > *_PMessage, _Inout_opt_ ISource< multi_link_registry< ISource< _Type > >::type::source_type > *_PSource)=0
 When overridden in a derived class, asynchronously passes a message from a source block to this target block. More...
 
virtual message_status send (_Inout_ message< multi_link_registry< ISource< _Type > >::type::source_type > *_PMessage, _Inout_ ISource< multi_link_registry< ISource< _Type > >::type::source_type > *_PSource)=0
 When overridden in a derived class, synchronously passes a message to the target block. More...
 
virtual bool supports_anonymous_source ()
 When overridden in a derived class, returns true or false depending on whether the message block accepts messages offered by a source that is not linked to it. If the overridden method returns true, the target cannot postpone an offered message, as consumption of a postponed message at a later time requires the source to be identified in its source link registry. More...
 

Protected Member Functions

virtual void resume_propagation ()
 Resumes propagation after a reservation has been released More...
 
virtual void link_target_notification (_Inout_ ITarget< size_t > *)
 Notification that a target was linked to this source. More...
 
void _Create_send_message ()
 Create a message that contains an index used to determine the source message More...
 
void _Initialize_order_node (ISource< _Type > *_PSource, size_t _Index, ITarget< size_t > *_PTarget, Scheduler *_PScheduler=NULL, ScheduleGroup *_PScheduleGroup=NULL)
 Validate constructor arguments and fully connect this _Order_node_base. More...
 
- Protected Member Functions inherited from Concurrency::propagator_block< single_link_registry< ITarget< size_t > >, multi_link_registry< ISource< _Type > > >
virtual message_status propagate_message (_Inout_ message< _Source_type > *_PMessage, _Inout_ ISource< _Source_type > *_PSource)=0
 When overridden in a derived class, this method asynchronously passes a message from an ISource block to this propagator_block object. It is invoked by the propagate method, when called by a source block. More...
 
virtual message_status send_message (_Inout_ message< _Source_type > *, _Inout_ ISource< _Source_type > *)
 When overridden in a derived class, this method synchronously passes a message from an ISource block to this propagator_block object. It is invoked by the send method, when called by a source block. More...
 
virtual void link_source (_Inout_ ISource< _Source_type > *_PSource)
 Links a specified source block to this propagator_block object. More...
 
virtual void unlink_source (_Inout_ ISource< _Source_type > *_PSource)
 Unlinks a specified source block from this propagator_block object. More...
 
virtual void unlink_sources ()
 Unlinks all source blocks from this propagator_block object. More...
 
virtual void process_input_messages (_Inout_ message< _Target_type > *)
 Process input messages. This is only useful for propagator blocks, which derive from source_block More...
 
void initialize_source_and_target (_Inout_opt_ Scheduler *_PScheduler=NULL, _Inout_opt_ ScheduleGroup *_PScheduleGroup=NULL)
 Initializes the base object. Specifically, the message_processor object needs to be initialized. More...
 
void register_filter (filter_method const &_Filter)
 Registers a filter method that will be invoked on every received message. More...
 
void decline_incoming_messages ()
 Indicates to the block that new messages should be declined. More...
 
void remove_network_links ()
 Removes all the source and target network links from this propagator_block object. More...
 
- Protected Member Functions inherited from Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >
virtual void link_target_notification (_Inout_ ITarget< _Target_type > *)
 A callback that notifies that a new target has been linked to this source_block object. More...
 
virtual void unlink_target_notification (_Inout_ ITarget< _Target_type > *_PTarget)
 A callback that notifies that a target has been unlinked from this source_block object. More...
 
virtual message< _Target_type > * accept_message (runtime_object_identity _MsgId)=0
 When overridden in a derived class, accepts an offered message by the source. Message blocks should override this method to validate the _MsgId and return a message. More...
 
virtual void propagate_output_messages ()
 Propagate messages to targets. More...
 
virtual void propagate_to_any_targets (_Inout_opt_ message< _Target_type > *_PMessage)
 When overridden in a derived class, propagates the given message to any or all of the linked targets. This is the main propagation routine for message blocks. More...
 
void initialize_source (_Inout_opt_ Scheduler *_PScheduler=NULL, _Inout_opt_ ScheduleGroup *_PScheduleGroup=NULL)
 Initializes the message_propagator within this source_block. More...
 
void enable_batched_processing ()
 Enables batched processing for this block. More...
 
virtual void sync_send (_Inout_opt_ message< _Target_type > *_Msg)
 Synchronously queues up messages and starts a propagation task, if this has not been done already. More...
 
virtual void async_send (_Inout_opt_ message< _Target_type > *_Msg)
 Asynchronously queues up messages and starts a propagation task, if this has not been done already More...
 
void wait_for_outstanding_async_sends ()
 Waits for all asynchronous propagations to complete. This propagator-specific spin wait is used in destructors of message blocks to make sure that all asynchronous propagations have time to finish before destroying the block. More...
 
void remove_targets ()
 Removes all target links for this source block. This should be called from the destructor. More...
 
- Protected Member Functions inherited from Concurrency::ISource< single_link_registry< ITarget< size_t > >::type::type >
void _Invoke_link_source (ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PLinkFrom)
 Links this source to a target. More...
 
void _Invoke_unlink_source (ITarget< single_link_registry< ITarget< size_t > >::type::type > *_PUnlinkFrom)
 Unlinks this source from a target. More...
 
- Protected Member Functions inherited from Concurrency::ITarget< multi_link_registry< ISource< _Type > >::type::source_type >
virtual void link_source (_Inout_ ISource< multi_link_registry< ISource< _Type > >::type::source_type > *_PSource)=0
 When overridden in a derived class, links a specified source block to this ITarget block. More...
 
virtual void unlink_source (_Inout_ ISource< multi_link_registry< ISource< _Type > >::type::source_type > *_PSource)=0
 When overridden in a derived class, unlinks a specified source block from this ITarget block. More...
 

Protected Attributes

message< _Type > * _M_pReceiveMessage
 
message< size_t > * _M_pSendMessage
 
size_t _M_index
 
- Protected Attributes inherited from Concurrency::propagator_block< single_link_registry< ITarget< size_t > >, multi_link_registry< ISource< _Type > > >
_SourceLinkManager _M_connectedSources
 The container for all the sources connected to this block. More...
 
filter_method_M_pFilter
 The filter function which determines whether offered messages should be accepted. More...
 
volatile bool _M_fDeclineMessages
 A bool that is set to indicate that all messages should be declined in preparation for deleting the block More...
 
- Protected Attributes inherited from Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >
ITarget< _Target_type > * _M_pReservedFor
 Connected target that is holding a reservation More...
 
runtime_object_identity _M_reservedId
 Reserved message ID More...
 
single_link_registry< ITarget< size_t > > _M_connectedTargets
 Connected targets More...
 
_MessageProcessorType _M_messageProcessor
 Processor used for asynchronous message handling More...
 

Private Member Functions

_Order_node_base const & operator= (_Order_node_base const &)
 
 _Order_node_base (_Order_node_base const &)
 

Additional Inherited Members

- Public Types inherited from Concurrency::propagator_block< single_link_registry< ITarget< size_t > >, multi_link_registry< ISource< _Type > > >
typedef multi_link_registry< ISource< _Type > >::type::source_type _Source_type
 The type of the payload for the incoming message to this propagator_block. More...
 
typedef source_link_manager< multi_link_registry< ISource< _Type > > > _SourceLinkManager
 The type of the source_link_manager this propagator_block. More...
 
typedef _SourceLinkManager::iterator source_iterator
 The type of the iterator for the source_link_manager for this propagator_block. More...
 
- Public Types inherited from Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >
typedef single_link_registry< ITarget< size_t > >::type::type _Target_type
 The payload type of messages handled by this source_block. More...
 
typedef single_link_registry< ITarget< size_t > >::iterator target_iterator
 The iterator to walk the connected targets. More...
 
- Public Types inherited from Concurrency::ISource< single_link_registry< ITarget< size_t > >::type::type >
typedef single_link_registry< ITarget< size_t > >::type::type source_type
 A type alias for _Type . More...
 
- Public Types inherited from Concurrency::ITarget< multi_link_registry< ISource< _Type > >::type::source_type >
typedef multi_link_registry< ISource< _Type > >::type::source_type type
 A type alias for _Type . More...
 
typedef std::function< bool(multi_link_registry< ISource< _Type > >::type::source_typeconst &)> filter_method
 The signature of any method used by the block that returns a bool value to determine whether an offered message should be accepted. More...
 

Detailed Description

template<class _Type>
class Concurrency::_Order_node_base< _Type >

Base class for Helper node used in multi-type join and choice blocks Order node is a single-target, single-source ordered propagator block The main property of an order node is that it accepts a message of _Type and outputs a message of int, with some unique assigned index number.

Template Parameters
_TypeThe payload type

Constructor & Destructor Documentation

template<class _Type>
Concurrency::_Order_node_base< _Type >::_Order_node_base ( )
inline

Constructs a _Order_node_base within the default scheduler, and places it on any schedule group of the scheduler's choosing.

9988  :
9989  _M_index(0),
9992  {
9993  }
message< _Type > * _M_pReceiveMessage
Definition: agents.h:10169
message< size_t > * _M_pSendMessage
Definition: agents.h:10172
size_t _M_index
Definition: agents.h:10175
#define NULL
Definition: corecrt.h:158
template<class _Type>
Concurrency::_Order_node_base< _Type >::~_Order_node_base ( )
inline

Cleans up any resources that may have been created by the _Order_node.

10000  {
10001  // The messages for an _Order_node_base are deleted at the end when
10002  // _Order_node_base is deleted.
10003  delete _M_pReceiveMessage;
10004  delete _M_pSendMessage;
10005  }
message< _Type > * _M_pReceiveMessage
Definition: agents.h:10169
message< size_t > * _M_pSendMessage
Definition: agents.h:10172
template<class _Type>
Concurrency::_Order_node_base< _Type >::_Order_node_base ( _Order_node_base< _Type > const &  )
private

Member Function Documentation

template<class _Type>
void Concurrency::_Order_node_base< _Type >::_Create_send_message ( )
inlineprotected

Create a message that contains an index used to determine the source message

10133  {
10134  _M_pSendMessage = new message<size_t>(_M_index);
10135  }
message< size_t > * _M_pSendMessage
Definition: agents.h:10172
size_t _M_index
Definition: agents.h:10175
template<class _Type>
void Concurrency::_Order_node_base< _Type >::_Initialize_order_node ( ISource< _Type > *  _PSource,
size_t  _Index,
ITarget< size_t > *  _PTarget,
Scheduler *  _PScheduler = NULL,
ScheduleGroup *  _PScheduleGroup = NULL 
)
inlineprotected

Validate constructor arguments and fully connect this _Order_node_base.

10142  {
10143  if (_PSource == NULL)
10144  {
10145  throw std::invalid_argument("_PSource");
10146  }
10147 
10148  _M_index = _Index;
10149 
10150  this->initialize_source_and_target(_PScheduler, _PScheduleGroup);
10151 
10152  // Allow only a single source and ensure that they
10153  // cannot be unlinked and relinked.
10154  this->_M_connectedSources.set_bound(1);
10155 
10156  if (_PTarget != NULL)
10157  {
10158  this->link_target(_PTarget);
10159  }
10160 
10161  _PSource->link_target(this);
10162  }
_In_ size_t _In_ int _Index
Definition: time.h:102
_SourceLinkManager _M_connectedSources
The container for all the sources connected to this block.
Definition: agents.h:5884
virtual void link_target(_Inout_ ITarget< _Target_type > *_PTarget)
Links a target block to this source_block object.
Definition: agents.h:4932
size_t _M_index
Definition: agents.h:10175
_Pre_maybenull_ _Inout_ _Deref_prepost_z_ wchar_t const _PSource
Definition: wchar.h:148
void initialize_source_and_target(_Inout_opt_ Scheduler *_PScheduler=NULL, _Inout_opt_ ScheduleGroup *_PScheduleGroup=NULL)
Initializes the base object. Specifically, the message_processor object needs to be initialized...
Definition: agents.h:5827
#define NULL
Definition: corecrt.h:158
template<class _Type>
virtual void Concurrency::_Order_node_base< _Type >::_Reset ( )
pure virtual

Resets the _Order_node_base and prepares it for the next propagation

_Reset is called from Populate_destination_tuple through propagate_to_any_targets() thus, it always has the internal lock held. This is only used for _Greedy_node and _Non_greedy_node.

Implemented in Concurrency::_Non_greedy_node< _Type >, Concurrency::_Greedy_node< _Type >, and Concurrency::_Reserving_node< _Type >.

template<class _Type>
virtual message<size_t>* Concurrency::_Order_node_base< _Type >::consume_message ( runtime_object_identity  )
inlinevirtual

Consumes a message previously offered by the source and reserved by the target, transferring ownership to the caller.

Parameters
_MsgIdThe runtime object identity of the message.
Returns
A pointer to the message that the caller now has ownership of.

Similar to 'accept', but is always preceded by a call to 'reserve'

Implements Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >.

10080  {
10081  // consume should never be called for this block.
10082  _CONCRT_ASSERT(false);
10083 
10084  return NULL;
10085  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
#define NULL
Definition: corecrt.h:158
template<class _Type>
bool Concurrency::_Order_node_base< _Type >::has_value ( ) const
inline

Checks whether this block has been initialized yet.

Returns
true, if the block has received a value, false otherwise.
10015  {
10016  return (_M_pReceiveMessage != NULL);
10017  }
message< _Type > * _M_pReceiveMessage
Definition: agents.h:10169
#define NULL
Definition: corecrt.h:158
template<class _Type>
virtual void Concurrency::_Order_node_base< _Type >::link_target_notification ( _Inout_ ITarget< size_t > *  )
inlineprotectedvirtual

Notification that a target was linked to this source.

Parameters
_PTargetA pointer to the newly linked target.
10121  {
10122  if (_M_pSendMessage != NULL)
10123  {
10125  }
10126  }
message< size_t > * _M_pSendMessage
Definition: agents.h:10172
virtual void propagate_to_any_targets(_Inout_opt_ message< _Target_type > *_PMessage)
When overridden in a derived class, propagates the given message to any or all of the linked targets...
Definition: agents.h:5362
#define NULL
Definition: corecrt.h:158
template<class _Type>
_Order_node_base const& Concurrency::_Order_node_base< _Type >::operator= ( _Order_node_base< _Type > const &  )
private
template<class _Type>
virtual void Concurrency::_Order_node_base< _Type >::release_message ( runtime_object_identity  )
inlinevirtual

Releases a previous message reservation.

Parameters
_MsgIdThe runtime object identity of the message.

Implements Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >.

10095  {
10096  // release should never be called for this block.
10097  _CONCRT_ASSERT(false);
10098  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
template<class _Type>
virtual bool Concurrency::_Order_node_base< _Type >::reserve_message ( runtime_object_identity  )
inlinevirtual

Reserves a message previously offered by the source.

Parameters
_MsgIdThe runtime object identity of the message.
Returns
A bool indicating whether the reservation worked or not

After 'reserve' is called, either 'consume' or 'release' must be called.

Implements Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >.

10058  {
10059  // reserve should never be called for this block.
10060  _CONCRT_ASSERT(false);
10061 
10062  return false;
10063  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
template<class _Type>
virtual void Concurrency::_Order_node_base< _Type >::resume_propagation ( )
inlineprotectedvirtual

Resumes propagation after a reservation has been released

Implements Concurrency::source_block< single_link_registry< ITarget< size_t > >, _MessageProcessorType >.

10108  {
10109  // Because there is only a single target, nothing needs
10110  // to be done on resume
10111  }
template<class _Type>
_Type const& Concurrency::_Order_node_base< _Type >::value ( )
inline

Gets a reference to the current payload of the message being stored.

Returns
The incoming payload.
10027  {
10029 
10030  return _M_pReceiveMessage->payload;
10031  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
message< _Type > * _M_pReceiveMessage
Definition: agents.h:10169
#define NULL
Definition: corecrt.h:158

Member Data Documentation

template<class _Type>
size_t Concurrency::_Order_node_base< _Type >::_M_index
protected
template<class _Type>
message<_Type>* Concurrency::_Order_node_base< _Type >::_M_pReceiveMessage
protected
template<class _Type>
message<size_t>* Concurrency::_Order_node_base< _Type >::_M_pSendMessage
protected

The documentation for this class was generated from the following file: