STLdoc
STLdocumentation
|
The target_block
class is an abstract base class that provides basic link management functionality and error checking for target only blocks.
More...
#include <agents.h>
Public Types | |
typedef _SourceLinkRegistry::type::source_type | _Source_type |
The type of the payload for the incoming messages to this target_block object. More... | |
typedef source_link_manager< _SourceLinkRegistry > | _SourceLinkManager |
The type of the source_link_manager this target_block object. More... | |
typedef _SourceLinkManager::iterator | source_iterator |
The type of the iterator for the source_link_manager for this target_block object. More... | |
Public Types inherited from Concurrency::ITarget< _SourceLinkRegistry::type::source_type > | |
typedef _SourceLinkRegistry::type::source_type | type |
A type alias for _Type . More... | |
typedef std::function< bool(_SourceLinkRegistry::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... | |
Public Member Functions | |
target_block () | |
Constructs a target_block object. More... | |
virtual | ~target_block () |
Destroys the target_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 passes a message from a source block to this target block. More... | |
Public Member Functions inherited from Concurrency::ITarget< _SourceLinkRegistry::type::source_type > | |
virtual | ~ITarget () |
Destroys the ITarget object. 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 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 target_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 target_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 target_block object. More... | |
virtual void | unlink_source (_Inout_ ISource< _Source_type > *_PSource) |
Unlinks a specified source block from this target_block object. More... | |
virtual void | unlink_sources () |
Unlinks all source blocks from this target_block object. More... | |
virtual void | process_message (message< _Source_type > *) |
When overridden in a derived class, processes a message that was accepted by this target_block object. More... | |
void | register_filter (filter_method const &_Filter) |
Registers a filter method that will be invoked on every message received. More... | |
void | decline_incoming_messages () |
Indicates to the block that new messages should be declined. More... | |
void | initialize_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 | enable_batched_processing () |
Enables batched processing for this block. More... | |
void | async_send (_Inout_opt_ message< _Source_type > *_PMessage) |
Asynchronously sends a message for processing. More... | |
void | sync_send (_Inout_opt_ message< _Source_type > *_PMessage) |
Synchronously send a message for processing. More... | |
void | wait_for_async_sends () |
Waits for all asynchronous propagations to complete. More... | |
void | remove_sources () |
Unlinks all sources after waiting for outstanding asynchronous send operations to complete. More... | |
virtual void | process_input_messages (_Inout_ message< _Source_type > *) |
Processes messages that are received as inputs. More... | |
Protected Attributes | |
_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... | |
bool | _M_fDeclineMessages |
A bool that is set to indicate that all messages should be declined in preparation for deleting the block More... | |
_MessageProcessorType | _M_messageProcessor |
The message_processor for this target_block . More... | |
The target_block
class is an abstract base class that provides basic link management functionality and error checking for target only blocks.
_SourceLinkRegistry | The link registry to be used for holding the source links. |
_MessageProcessorType | The processor type for message processing. |
typedef _SourceLinkRegistry::type::source_type Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >::_Source_type |
The type of the payload for the incoming messages to this target_block
object.
typedef source_link_manager<_SourceLinkRegistry> Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >::_SourceLinkManager |
The type of the source_link_manager
this target_block
object.
typedef _SourceLinkManager::iterator Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >::source_iterator |
The type of the iterator for the source_link_manager
for this target_block
object.
|
inline |
Constructs a target_block
object.
|
inlinevirtual |
Destroys the target_block
object.
|
inlineprotected |
Asynchronously sends a message for processing.
_PMessage | A pointer to the message being sent. |
|
inlineprotected |
Indicates to the block that new messages should be declined.
This method is called by the destructor to ensure that new messages are declined while destruction is in progress.
|
inlineprotected |
Enables batched processing for this block.
|
inlineprotected |
Initializes the base object. Specifically, the message_processor
object needs to be initialized.
_PScheduler | The scheduler to be used for scheduling tasks. |
_PScheduleGroup | The schedule group to be used for scheduling tasks. |
|
inlineprotectedvirtual |
Links a specified source block to this target_block
object.
_PSource | A pointer to the ISource block that is to be linked. |
This function should not be called directly on a target_block
object. Blocks should be connected together using the link_target
method on ISource
blocks, which will invoke the link_source
method on the corresponding target.
Implements Concurrency::ITarget< _SourceLinkRegistry::type::source_type >.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
When overridden in a derived class, processes a message that was accepted by this target_block
object.
_PMessage | A pointer to the message that is to be handled. |
|
inlinevirtual |
Asynchronously passes a message from a source block to this target block.
_PMessage | A pointer to the message object. |
_PSource | A pointer to the source block offering the message. |
The method throws an invalid_argument exception if either the _PMessage or _PSource parameter is NULL
.
Implements Concurrency::ITarget< _SourceLinkRegistry::type::source_type >.
|
protectedpure virtual |
When overridden in a derived class, this method asynchronously passes a message from an ISource
block to this target_block
object. It is invoked by the propagate
method, when called by a source block.
_PMessage | A pointer to the message object. |
_PSource | A pointer to the source block offering the message. |
|
inlineprotected |
Registers a filter method that will be invoked on every message received.
_Filter | The filter method. |
|
inlineprotected |
Unlinks all sources after waiting for outstanding asynchronous send operations to complete.
All target blocks should call this routine to remove the sources in their destructor.
|
inlinevirtual |
Synchronously passes a message from a source block to this target block.
_PMessage | A pointer to the message object. |
_PSource | A pointer to the source block offering the message. |
The method throws an invalid_argument exception if either the _PMessage or _PSource parameter is NULL
.
Using the send
method outside of message initiation and to propagate messages within a network is dangerous and can lead to deadlock.
When send
returns, the message has either already been accepted, and transferred into the target block, or it has been declined by the target.
Implements Concurrency::ITarget< _SourceLinkRegistry::type::source_type >.
|
inlineprotectedvirtual |
When overridden in a derived class, this method synchronously passes a message from an ISource
block to this target_block
object. It is invoked by the send
method, when called by a source block.
_PMessage | A pointer to the message object. |
_PSource | A pointer to the source block offering the message. |
By default, this block returns declined
unless overridden by a derived class.
|
inlineprotected |
Synchronously send a message for processing.
_PMessage | A pointer to the message being sent. |
|
inlineprotectedvirtual |
Unlinks a specified source block from this target_block
object.
_PSource | A pointer to the ISource block that is to be unlinked. |
This function should not be called directly on n target_block
object. Blocks should be disconnected using the unlink_target
or unlink_targets
methods on ISource
blocks, which will invoke the unlink_source
method on the corresponding target.
Implements Concurrency::ITarget< _SourceLinkRegistry::type::source_type >.
|
inlineprotectedvirtual |
Unlinks all source blocks from this target_block
object.
Implements Concurrency::ITarget< _SourceLinkRegistry::type::source_type >.
|
inlineprotected |
Waits for all asynchronous propagations to complete.
This method is used by message block destructors to ensure all asynchronous operations have had time to finish before destroying the block.
|
protected |
The container for all the sources connected to this block.
|
protected |
A bool
that is set to indicate that all messages should be declined in preparation for deleting the block
|
protected |
The message_processor
for this target_block
.
|
protected |
The filter function which determines whether offered messages should be accepted.