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

A single_assignment messaging block is a multi-target, multi-source, ordered propagator_block capable of storing a single, write-once message. More...

#include <agents.h>

Inheritance diagram for Concurrency::single_assignment< _Type >:
Concurrency::propagator_block< multi_link_registry< ITarget< _Type > >, multi_link_registry< ISource< _Type > > > Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType > Concurrency::ITarget< multi_link_registry< ISource< _Type > >::type::source_type > Concurrency::ISource< multi_link_registry< ITarget< _Type > >::type::type >

Public Member Functions

 single_assignment ()
 Constructs a single_assignment messaging block. More...
 
 single_assignment (filter_method const &_Filter)
 Constructs a single_assignment messaging block. More...
 
 ~single_assignment ()
 Destroys the single_assignment messaging block. More...
 
bool has_value () const
 Checks whether this single_assignment messaging block has been initialized with a value yet. More...
 
_Type const & value ()
 Gets a reference to the current payload of the message being stored in the single_assignment messaging block. More...
 
- Public Member Functions inherited from Concurrency::propagator_block< multi_link_registry< ITarget< _Type > >, 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< multi_link_registry< ITarget< _Type > >, _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< multi_link_registry< ITarget< _Type > >::type::type >
virtual ~ISource ()
 Destroys the ISource object. More...
 
virtual void link_target (_Inout_ ITarget< multi_link_registry< ITarget< _Type > >::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< multi_link_registry< ITarget< _Type > >::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< multi_link_registry< ITarget< _Type > >::type::type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< multi_link_registry< ITarget< _Type > >::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< multi_link_registry< ITarget< _Type > >::type::type > *_PTarget)=0
 When overridden in a derived class, reserves a message previously offered by this ISource block. More...
 
virtual message< multi_link_registry< ITarget< _Type > >::type::type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< multi_link_registry< ITarget< _Type > >::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< multi_link_registry< ITarget< _Type > >::type::type > *_PTarget)=0
 When overridden in a derived class, releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< multi_link_registry< ITarget< _Type > >::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< multi_link_registry< ITarget< _Type > >::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 sourse link registry. More...
 

Protected Member Functions

virtual message_status propagate_message (_Inout_ message< _Type > *_PMessage, _Inout_ ISource< _Type > *_PSource)
 Asynchronously passes a message from an ISource block to this single_assignment messaging block. It is invoked by the propagate method, when called by a source block. More...
 
virtual message_status send_message (_Inout_ message< _Type > *_PMessage, _Inout_ ISource< _Type > *_PSource)
 Synchronously passes a message from an ISource block to this single_assignment messaging block. It is invoked by the send method, when called by a source block. More...
 
virtual message< _Type > * accept_message (runtime_object_identity _MsgId)
 Accepts a message that was offered by this single_assignment messaging block, returning a copy of the message to the caller. More...
 
virtual bool reserve_message (runtime_object_identity _MsgId)
 Reserves a message previously offered by this single_assignment messaging block. More...
 
virtual message< _Type > * consume_message (runtime_object_identity _MsgId)
 Consumes a message previously offered by the single_assignment and reserved by the target, returning a copy of the message to the caller. More...
 
virtual void release_message (runtime_object_identity _MsgId)
 Releases a previous message reservation. More...
 
virtual void resume_propagation ()
 Resumes propagation after a reservation has been released. More...
 
virtual void link_target_notification (_Inout_ ITarget< _Type > *_PTarget)
 A callback that notifies that a new target has been linked to this single_assignment messaging block. More...
 
virtual void propagate_to_any_targets (_Inout_opt_ message< _Type > *_PMessage)
 Places the message _PMessage in this single_assignment messaging block and offers it to all of the linked targets. More...
 
- Protected Member Functions inherited from Concurrency::propagator_block< multi_link_registry< ITarget< _Type > >, 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 > *_PMessage)
 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< multi_link_registry< ITarget< _Type > >, _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 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< multi_link_registry< ITarget< _Type > >::type::type >
void _Invoke_link_source (ITarget< multi_link_registry< ITarget< _Type > >::type::type > *_PLinkFrom)
 Links this source to a target. More...
 
void _Invoke_unlink_source (ITarget< multi_link_registry< ITarget< _Type > >::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...
 

Private Member Functions

void _Delete_stored_messages ()
 Deletes all messages currently stored in this message block. Should be called by the destructor to ensure any messages propagated in are cleaned up. More...
 
single_assignment const & operator= (single_assignment const &)
 
 single_assignment (single_assignment const &)
 

Private Attributes

message< _Type > * _M_pMessage
 
::Concurrency::details::_NonReentrantPPLLock _M_propagationLock
 
volatile bool _M_fIsInitialized
 

Additional Inherited Members

- Public Types inherited from Concurrency::propagator_block< multi_link_registry< ITarget< _Type > >, 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< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >
typedef multi_link_registry< ITarget< _Type > >::type::type _Target_type
 The payload type of messages handled by this source_block. More...
 
typedef multi_link_registry< ITarget< _Type > >::iterator target_iterator
 The iterator to walk the connected targets. More...
 
- Public Types inherited from Concurrency::ISource< multi_link_registry< ITarget< _Type > >::type::type >
typedef multi_link_registry< ITarget< _Type > >::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::tr1::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...
 
- Protected Attributes inherited from Concurrency::propagator_block< multi_link_registry< ITarget< _Type > >, 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< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >
ITarget< _Target_type > * _M_pReservedFor
 Connected target that is holding a reservation More...
 
runtime_object_identity _M_reservedId
 Reserved message ID More...
 
multi_link_registry< ITarget< _Type > > _M_connectedTargets
 Connected targets More...
 
_MessageProcessorType _M_messageProcessor
 Processor used for asynchronous message handling More...
 

Detailed Description

template<class _Type>
class Concurrency::single_assignment< _Type >

A single_assignment messaging block is a multi-target, multi-source, ordered propagator_block capable of storing a single, write-once message.

Template Parameters
_TypeThe payload type of the message stored and propagated by the buffer.

A single_assignment messaging block propagates out copies of its message to each target.

For more information, see Asynchronous Message Blocks.

See also
overwrite_buffer Class, unbounded_buffer Class

Constructor & Destructor Documentation

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

Constructs a single_assignment messaging block.

The runtime uses the default scheduler if you do not specify the _PScheduler or _PScheduleGroup parameters.

The type filter_method is a functor with signature bool (_Type const &) which is invoked by this single_assignment messaging block to determine whether or not it should accept an offered message.

See also
Scheduler Class, ScheduleGroup Class
6920  :
6922  {
6924  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
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:4173
template<class _Type>
Concurrency::single_assignment< _Type >::single_assignment ( filter_method const &  _Filter)
inline

Constructs a single_assignment messaging block.

Parameters
_FilterA filter function which determines whether offered messages should be accepted.

The runtime uses the default scheduler if you do not specify the _PScheduler or _PScheduleGroup parameters.

The type filter_method is a functor with signature bool (_Type const &) which is invoked by this single_assignment messaging block to determine whether or not it should accept an offered message.

See also
Scheduler Class, ScheduleGroup Class
6942  :
6944  {
6946  register_filter(_Filter);
6947  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
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:4173
void register_filter(filter_method const &_Filter)
Registers a filter method that will be invoked on every received message.
Definition: agents.h:4188
template<class _Type>
Concurrency::single_assignment< _Type >::~single_assignment ( )
inline

Destroys the single_assignment messaging block.

7054  {
7055  // Remove all links
7057 
7058  // Clean up any messages left in this message block
7060  }
void _Delete_stored_messages()
Deletes all messages currently stored in this message block. Should be called by the destructor to en...
Definition: agents.h:7386
void remove_network_links()
Removes all the source and target network links from this propagator_block object.
Definition: agents.h:4212
template<class _Type>
Concurrency::single_assignment< _Type >::single_assignment ( single_assignment< _Type > const &  )
private

Member Function Documentation

template<class _Type>
void Concurrency::single_assignment< _Type >::_Delete_stored_messages ( )
inlineprivate

Deletes all messages currently stored in this message block. Should be called by the destructor to ensure any messages propagated in are cleaned up.

7387  {
7388  // Input messages for this message block are in the base-class input buffer
7389  // All messages in that buffer are guaranteed to have moved to the output
7390  // buffer because the destructor first waits for all async sends to finish
7391  // before reaching this point
7392 
7393  // The messages for a single_assignment are deleted at the end when
7394  // single_assignment is deleted.
7395  delete _M_pMessage;
7396  }
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual message<_Type>* Concurrency::single_assignment< _Type >::accept_message ( runtime_object_identity  _MsgId)
inlineprotectedvirtual

Accepts a message that was offered by this single_assignment messaging block, returning a copy of the message to the caller.

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

The single_assignment messaging block returns copies of the message to its targets, rather than transferring ownership of the currently held message.

Implements Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >.

7240  {
7241  // This check is to prevent spoofing and verify that the propagated message is
7242  // the one that is accepted at the end.
7243  if (_M_pMessage == NULL || _MsgId != _M_pMessage->msg_id())
7244  {
7245  return NULL;
7246  }
7247 
7248  //
7249  // Instead of returning the internal message, we return a copy of the
7250  // message passed in.
7251  //
7252  // Because we are returning a copy, the accept routine for a single_assignment
7253  // does not need to grab the internal lock.
7254  //
7255  return (new message<_Type>(_M_pMessage->payload));
7256  }
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual message<_Type>* Concurrency::single_assignment< _Type >::consume_message ( runtime_object_identity  _MsgId)
inlineprotectedvirtual

Consumes a message previously offered by the single_assignment and reserved by the target, returning a copy of the message to the caller.

Parameters
_MsgIdThe runtime_object_identity of the message object being consumed.
Returns
A pointer to the message object that the caller now has ownership of.

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

Implements Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >.

7302  {
7304 
7305  return accept_message(_MsgId);
7306  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
virtual message< _Type > * accept_message(runtime_object_identity _MsgId)
Accepts a message that was offered by this single_assignment messaging block, returning a copy of the...
Definition: agents.h:7239
template<class _Type>
bool Concurrency::single_assignment< _Type >::has_value ( ) const
inline

Checks whether this single_assignment messaging block has been initialized with a value yet.

Returns
true if the block has received a value, false otherwise.
7070  {
7071  return (_M_pMessage != NULL);
7072  }
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual void Concurrency::single_assignment< _Type >::link_target_notification ( _Inout_ ITarget< _Type > *  _PTarget)
inlineprotectedvirtual

A callback that notifies that a new target has been linked to this single_assignment messaging block.

Parameters
_PTargetA pointer to the newly linked target.
7343  {
7344  // If there is a message available already, propagate it.
7345 
7346  if (_M_pMessage != NULL)
7347  {
7348  _PTarget->propagate(_M_pMessage, this);
7349  }
7350  }
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
single_assignment const& Concurrency::single_assignment< _Type >::operator= ( single_assignment< _Type > const &  )
private
template<class _Type>
virtual message_status Concurrency::single_assignment< _Type >::propagate_message ( _Inout_ message< _Type > *  _PMessage,
_Inout_ ISource< _Type > *  _PSource 
)
inlineprotectedvirtual

Asynchronously passes a message from an ISource block to this single_assignment messaging block. It is invoked by the propagate method, when called by a source block.

Parameters
_PMessageA pointer to the message object.
_PSourceA pointer to the source block offering the message.
Returns
A message_status indication of what the target decided to do with the message.
7115  {
7116  // It is important that calls to propagate do *not* take the same lock on the
7117  // internal structure that is used by Consume and the LWT. Doing so could
7118  // result in a deadlock with the Consume call.
7119 
7120  message_status _Result = accepted;
7121 
7122  // single_assignment messaging block can be initialized only once
7123  if (_M_fIsInitialized)
7124  {
7125  return declined;
7126  }
7127 
7128  {
7130 
7131  if (_M_fIsInitialized)
7132  {
7133  _Result = declined;
7134  }
7135  else
7136  {
7137  _PMessage = _PSource->accept(_PMessage->msg_id(), this);
7138 
7139  // Set initialized flag only if we have a message
7140  if (_PMessage != NULL)
7141  {
7142  _M_fIsInitialized = true;
7143  }
7144  else
7145  {
7146  _Result = missed;
7147  }
7148  }
7149  }
7150 
7151  //
7152  // If message was accepted, set the member variables for
7153  // this block and start the asynchronous propagation task
7154  //
7155  if (_Result == accepted)
7156  {
7157  async_send(_PMessage);
7158  }
7159 
7160  return _Result;
7161  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
The target did not accept the message.
Definition: agents.h:1750
#define NULL
Definition: crtdbg.h:30
message_status
The valid responses for an offer of a message object to a block.
Definition: agents.h:1739
The target tried to accept the message, but it was no longer available.
Definition: agents.h:1760
The target accepted the message.
Definition: agents.h:1745
::Concurrency::details::_NonReentrantPPLLock::_Scoped_lock _NR_lock
A lock holder that acquires a non-reentrant lock on instantiation and releases it on destruction...
Definition: agents.h:57
::Concurrency::details::_NonReentrantPPLLock _M_propagationLock
Definition: agents.h:7406
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 ...
Definition: agents.h:3783
template<class _Type>
virtual void Concurrency::single_assignment< _Type >::propagate_to_any_targets ( _Inout_opt_ message< _Type > *  _PMessage)
inlineprotectedvirtual

Places the message _PMessage in this single_assignment messaging block and offers it to all of the linked targets.

Parameters
_PMessageA pointer to a message that this single_assignment messaging block has taken ownership of.
7360  {
7361  // Initialized flag should have been set by the propagate function using interlocked operation.
7363 
7364  // Move the message to the internal storage
7365 
7367  _M_pMessage = _PMessage;
7368 
7369  for (target_iterator _Iter = _M_connectedTargets.begin(); *_Iter != NULL; ++_Iter)
7370  {
7371  // Single assignment can propagate its message out
7372  // to any number of Targets
7373 
7374  ITarget<_Type> * _PTarget = *_Iter;
7375  _PTarget->propagate(_PMessage, this);
7376  }
7377  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
multi_link_registry< ITarget< _Type > >::iterator target_iterator
The iterator to walk the connected targets.
Definition: agents.h:3242
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
multi_link_registry< ITarget< _Type > > _M_connectedTargets
Connected targets
Definition: agents.h:3833
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual void Concurrency::single_assignment< _Type >::release_message ( runtime_object_identity  _MsgId)
inlineprotectedvirtual

Releases a previous message reservation.

Parameters
_MsgIdThe runtime_object_identity of the message object being released.

Implements Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >.

7316  {
7318 
7319  if (_M_pMessage == NULL || _M_pMessage->msg_id() != _MsgId)
7320  {
7321  throw message_not_found();
7322  }
7323  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual bool Concurrency::single_assignment< _Type >::reserve_message ( runtime_object_identity  _MsgId)
inlineprotectedvirtual

Reserves a message previously offered by this single_assignment messaging block.

Parameters
_MsgIdThe runtime_object_identity of the message object being reserved.
Returns
true if the message was successfully reserved, false otherwise.

After reserve is called, if it returns true, either consume or release must be called to either take or release ownership of the message.

Implements Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >.

7273  {
7274  if (_M_pMessage == NULL)
7275  {
7276  return false;
7277  }
7278 
7279  if (_M_pMessage->msg_id() != _MsgId)
7280  {
7281  throw message_not_found();
7282  }
7283 
7284  return true;
7285  }
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403
template<class _Type>
virtual void Concurrency::single_assignment< _Type >::resume_propagation ( )
inlineprotectedvirtual

Resumes propagation after a reservation has been released.

Implements Concurrency::source_block< multi_link_registry< ITarget< _Type > >, _MessageProcessorType >.

7330  {
7331  // Because reservation doesn't stop propagation, we don't
7332  // need to do anything on resume after consume/release.
7333  }
template<class _Type>
virtual message_status Concurrency::single_assignment< _Type >::send_message ( _Inout_ message< _Type > *  _PMessage,
_Inout_ ISource< _Type > *  _PSource 
)
inlineprotectedvirtual

Synchronously passes a message from an ISource block to this single_assignment messaging block. It is invoked by the send method, when called by a source block.

Parameters
_PMessageA pointer to the message object.
_PSourceA pointer to the source block offering the message.
Returns
A message_status indication of what the target decided to do with the message.
7179  {
7180  message_status _Result = accepted;
7181 
7182  // single_assignment messaging block can be initialized only once
7183  if (_M_fIsInitialized)
7184  {
7185  return declined;
7186  }
7187 
7188  {
7190 
7191  if (_M_fIsInitialized)
7192  {
7193  _Result = declined;
7194  }
7195  else
7196  {
7197  _PMessage = _PSource->accept(_PMessage->msg_id(), this);
7198 
7199  // Set initialized flag only if we have a message
7200  if (_PMessage != NULL)
7201  {
7202  _M_fIsInitialized = true;
7203  }
7204  else
7205  {
7206  _Result = missed;
7207  }
7208  }
7209  }
7210 
7211  //
7212  // If message was accepted, set the member variables for
7213  // this block and start the asynchronous propagation task
7214  //
7215  if (_Result == accepted)
7216  {
7217  sync_send(_PMessage);
7218  }
7219 
7220  return _Result;
7221  }
volatile bool _M_fIsInitialized
Definition: agents.h:7409
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...
Definition: agents.h:3769
The target did not accept the message.
Definition: agents.h:1750
#define NULL
Definition: crtdbg.h:30
message_status
The valid responses for an offer of a message object to a block.
Definition: agents.h:1739
The target tried to accept the message, but it was no longer available.
Definition: agents.h:1760
The target accepted the message.
Definition: agents.h:1745
::Concurrency::details::_NonReentrantPPLLock::_Scoped_lock _NR_lock
A lock holder that acquires a non-reentrant lock on instantiation and releases it on destruction...
Definition: agents.h:57
::Concurrency::details::_NonReentrantPPLLock _M_propagationLock
Definition: agents.h:7406
template<class _Type>
_Type const& Concurrency::single_assignment< _Type >::value ( )
inline

Gets a reference to the current payload of the message being stored in the single_assignment messaging block.

Returns
The payload of the stored message.

This method will wait until a message arrives if no message is currently stored in the single_assignment messaging block.

7086  {
7087  if (_M_pMessage == NULL)
7088  {
7089  receive<_Type>(this);
7090  }
7092 
7093  return _M_pMessage->payload;
7094  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
#define NULL
Definition: crtdbg.h:30
message< _Type > * _M_pMessage
Definition: agents.h:7403

Member Data Documentation

template<class _Type>
volatile bool Concurrency::single_assignment< _Type >::_M_fIsInitialized
private
template<class _Type>
message<_Type>* Concurrency::single_assignment< _Type >::_M_pMessage
private
template<class _Type>
::Concurrency::details::_NonReentrantPPLLock Concurrency::single_assignment< _Type >::_M_propagationLock
private

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