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

The ISource class is the interface for all source blocks. Source blocks propagate messages to ITarget blocks. More...

#include <agents.h>

Inheritance diagram for Concurrency::ISource< _Type >:
Concurrency::details::_AnonymousOriginator< _Type > Concurrency::details::_AsyncOriginator< _Type > Concurrency::details::_SyncOriginator< _Type >

Public Types

typedef _Type source_type
 A type alias for _Type . More...
 

Public Member Functions

virtual ~ISource ()
 Destroys the ISource object. More...
 
virtual void link_target (_Inout_ ITarget< _Type > *_PTarget)=0
 When overridden in a derived class, links a target block to this ISource block. More...
 
virtual void unlink_target (_Inout_ ITarget< _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 void unlink_targets ()=0
 When overridden in a derived class, unlinks all target blocks from this ISource block. More...
 
virtual message< _Type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< _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< _Type > *_PTarget)=0
 When overridden in a derived class, reserves a message previously offered by this ISource block. More...
 
virtual message< _Type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< _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< _Type > *_PTarget)=0
 When overridden in a derived class, releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< _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< _Type > *_PTarget)=0
 When overridden in a derived class, releases a reference count on this ISource block. More...
 

Protected Member Functions

void _Invoke_link_source (ITarget< _Type > *_PLinkFrom)
 Links this source to a target. More...
 
void _Invoke_unlink_source (ITarget< _Type > *_PUnlinkFrom)
 Unlinks this source from a target. More...
 

Detailed Description

template<class _Type>
class Concurrency::ISource< _Type >

The ISource class is the interface for all source blocks. Source blocks propagate messages to ITarget blocks.

Template Parameters
_TypeThe data type of the payload within the messages produced by the source block.

For more information, see Asynchronous Message Blocks.

See also
ITarget Class

Member Typedef Documentation

template<class _Type>
typedef _Type Concurrency::ISource< _Type >::source_type

A type alias for _Type .

Constructor & Destructor Documentation

template<class _Type>
virtual Concurrency::ISource< _Type >::~ISource ( )
inlinevirtual

Destroys the ISource object.

2605 {}

Member Function Documentation

template<class _Type>
void Concurrency::ISource< _Type >::_Invoke_link_source ( ITarget< _Type > *  _PLinkFrom)
inlineprotected

Links this source to a target.

Parameters
_PLinkFromA pointer to the target.

This function definition is required because ISource blocks need to call Target->link_source(), which is a private member of ITarget. ISource is declared as a friend class, so this is a way for derived classes of ISource to properly link/unlink their targets during link_target(), unlink_target() and unlink_targets()

2755  {
2756  _PLinkFrom->link_source(this);
2757  }
template<class _Type>
void Concurrency::ISource< _Type >::_Invoke_unlink_source ( ITarget< _Type > *  _PUnlinkFrom)
inlineprotected

Unlinks this source from a target.

Parameters
_PUnlinkFromA pointer to the target.

This function definition is required because ISource blocks need to call Target->unlink_source(), which is a private member of ITarget. ISource is declared as a friend class, so this is a way for derived classes of ISource to properly link/unlink their targets during link_target(), unlink_target() and unlink_targets()

2774  {
2775  _PUnlinkFrom->unlink_source(this);
2776  }
template<class _Type>
virtual message<_Type>* Concurrency::ISource< _Type >::accept ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Type > *  _PTarget 
)
pure virtual

When overridden in a derived class, accepts a message that was offered by this ISource block, transferring ownership to the caller.

Parameters
_MsgIdThe runtime_object_identity of the offered message object.
_PTargetA pointer to the target block that is calling the accept method.
Returns
A pointer to the message that the caller now has ownership of.

The accept method is called by a target while a message is being offered by this ISource block. The message pointer returned may be different from the one passed into the propagate method of the ITarget block, if this source decides to make a copy of the message.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::acquire_ref ( _Inout_ ITarget< _Type > *  _PTarget)
pure virtual

When overridden in a derived class, acquires a reference count on this ISource block, to prevent deletion.

Parameters
_PTargetA pointer to the target block that is calling this method.

This method is called by an ITarget object that is being linked to this source during the link_target method.

Implemented in Concurrency::choice< _Type >, Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >, Concurrency::details::_AsyncOriginator< _Type >, Concurrency::details::_SyncOriginator< _Type >, and Concurrency::details::_AnonymousOriginator< _Type >.

template<class _Type>
virtual message<_Type>* Concurrency::ISource< _Type >::consume ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Type > *  _PTarget 
)
pure virtual

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.

Parameters
_MsgIdThe runtime_object_identity of the reserved message object.
_PTargetA pointer to the target block that is calling the consume method.
Returns
A pointer to the message object that the caller now has ownership of.

The consume method is similar to accept, but must always be preceded by a call to reserve that returned true.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::link_target ( _Inout_ ITarget< _Type > *  _PTarget)
pure virtual

When overridden in a derived class, links a target block to this ISource block.

Parameters
_PTargetA pointer to the target block being linked to this ISource block.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::release ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Type > *  _PTarget 
)
pure virtual

When overridden in a derived class, releases a previous successful message reservation.

Parameters
_MsgIdThe runtime_object_identity of the reserved message object.
_PTargetA pointer to the target block that is calling the release method.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::release_ref ( _Inout_ ITarget< _Type > *  _PTarget)
pure virtual

When overridden in a derived class, releases a reference count on this ISource block.

Parameters
_PTargetA pointer to the target block that is calling this method.

This method is called by an ITarget object that is being unlinked from this source. The source block is allowed to release any resources reserved for the target block.

Implemented in Concurrency::choice< _Type >, Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >, Concurrency::details::_AsyncOriginator< _Type >, Concurrency::details::_SyncOriginator< _Type >, and Concurrency::details::_AnonymousOriginator< _Type >.

template<class _Type>
virtual bool Concurrency::ISource< _Type >::reserve ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Type > *  _PTarget 
)
pure virtual

When overridden in a derived class, reserves a message previously offered by this ISource block.

Parameters
_MsgIdThe runtime_object_identity of the offered message object.
_PTargetA pointer to the target block that is calling the reserve method.
Returns
true if the message was successfully reserved, false otherwise. Reservations can fail for many reasons, including: the message was already reserved or accepted by another target, the source could deny reservations, and so forth.

After you call reserve, if it succeeds, you must call either consume or release in order to take or give up possession of the message, respectively.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::unlink_target ( _Inout_ ITarget< _Type > *  _PTarget)
pure virtual

When overridden in a derived class, unlinks a target block from this ISource block, if found to be previously linked.

Parameters
_PTargetA pointer to the target block being unlinked from this ISource block.

Implemented in Concurrency::choice< _Type >, and Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ISource< _Type >::unlink_targets ( )
pure virtual

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