|
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 bool | reserve_message (runtime_object_identity _MsgId)=0 |
| When overridden in a derived class, reserves a message previously offered by this source_block object. More...
|
|
virtual message< _Target_type > * | consume_message (runtime_object_identity _MsgId)=0 |
| When overridden in a derived class, consumes a message that was previously reserved. More...
|
|
virtual void | release_message (runtime_object_identity _MsgId)=0 |
| When overridden in a derived class, releases a previous message reservation. More...
|
|
virtual void | resume_propagation ()=0 |
| When overridden in a derived class, resumes propagation after a reservation has been released. 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...
|
|
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...
|
|
void | _Invoke_link_source (ITarget< _TargetLinkRegistry::type::type > *_PLinkFrom) |
| Links this source to a target. More...
|
|
void | _Invoke_unlink_source (ITarget< _TargetLinkRegistry::type::type > *_PUnlinkFrom) |
| Unlinks this source from a target. More...
|
|
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
class Concurrency::source_block< _TargetLinkRegistry, _MessageProcessorType >
The source_block
class is an abstract base class for source-only blocks. The class provides basic link management functionality as well as common error checks.
- Template Parameters
-
_TargetLinkRegistry | Link registry to be used for holding the target links. |
_MessageProcessorType | Processor type for message processing. |
Message blocks should derive from this block to take advantage of link management and synchronization provided by this class.
- See also
- ISource Class
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
Accepts a message that was offered by this source_block
object, transferring ownership to the caller.
- Parameters
-
_MsgId | The runtime_object_identity of the offered message object. |
_PTarget | A pointer to the target block that is calling the accept method. |
- Returns
- A pointer to the
message
object that the caller now has ownership of.
The method throws an invalid_argument exception if the parameter _PTarget is NULL
.
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.
Implements Concurrency::ISource< _TargetLinkRegistry::type::type >.
3367 if (_PTarget ==
NULL)
3369 throw std::invalid_argument(
"_PTarget");
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_TargetLinkRegistry _M_connectedTargets
Connected targets
Definition: agents.h:3833
#define NULL
Definition: crtdbg.h:30
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 o...
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
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.
- Parameters
-
_MsgId | The runtime object identity of the message object. |
- Returns
- A pointer to the message that the caller now has ownership of.
To transfer ownership, the original message pointer should be returned. To maintain ownership, a copy of message payload needs to be made and returned.
Implemented in Concurrency::_Join_node< _Type, _Destination_type, _Jtype >, Concurrency::_Non_greedy_node< _Type >, Concurrency::_Greedy_node< _Type >, Concurrency::_Reserving_node< _Type >, Concurrency::join< _Type, _Jtype >, Concurrency::single_assignment< _Type >, Concurrency::single_assignment< size_t >, Concurrency::timer< _Type >, Concurrency::transformer< _Input, _Output >, Concurrency::overwrite_buffer< _Type >, Concurrency::overwrite_buffer< agent_status >, and Concurrency::unbounded_buffer< _Type >.
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
Consumes a message previously offered by this source_block
object and successfully reserved by the target, transferring ownership to the caller.
- Parameters
-
_MsgId | The runtime_object_identity of the reserved message object. |
_PTarget | A 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 method throws an invalid_argument exception if the parameter _PTarget is NULL
.
The method throws a bad_target exception if the parameter _PTarget does not represent the target that called reserve
.
The consume
method is similar to accept
, but must always be preceded by a call to reserve
that returned true
.
Implements Concurrency::ISource< _TargetLinkRegistry::type::type >.
3461 if (_PTarget ==
NULL)
3463 throw std::invalid_argument(
"_PTarget");
virtual message< _Target_type > * consume_message(runtime_object_identity _MsgId)=0
When overridden in a derived class, consumes a message that was previously reserved.
virtual void resume_propagation()=0
When overridden in a derived class, resumes propagation after a reservation has been released...
#define NULL
Definition: crtdbg.h:30
::Concurrency::details::_ReentrantPPLLock::_Scoped_lock _R_lock
A lock holder that acquires a reentrant lock on instantiation and releases it on destruction ...
Definition: agents.h:64
::Concurrency::details::_ReentrantPPLLock _M_internalLock
Internal lock used for the following synchronization:
Definition: agents.h:3895
ITarget< _Target_type > * _M_pReservedFor
Connected target that is holding a reservation
Definition: agents.h:3821
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
When overridden in a derived class, consumes a message that was previously reserved.
- Parameters
-
_MsgId | The runtime_object_identity of the message object being consumed. |
- 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
.
Implemented in Concurrency::_Join_node< _Type, _Destination_type, _Jtype >, Concurrency::_Order_node_base< _Type >, Concurrency::join< _Type, _Jtype >, Concurrency::single_assignment< _Type >, Concurrency::single_assignment< size_t >, Concurrency::timer< _Type >, Concurrency::transformer< _Input, _Output >, Concurrency::overwrite_buffer< _Type >, Concurrency::overwrite_buffer< agent_status >, and Concurrency::unbounded_buffer< _Type >.
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
Releases a previous successful message reservation.
- Parameters
-
_MsgId | The runtime_object_identity of the reserved message object. |
_PTarget | A pointer to the target block that is calling the release method. |
The method throws an invalid_argument exception if the parameter _PTarget is NULL
.
The method throws a bad_target exception if the parameter _PTarget does not represent the target that called reserve
.
Implements Concurrency::ISource< _TargetLinkRegistry::type::type >.
3510 if (_PTarget ==
NULL)
3512 throw std::invalid_argument(
"_PTarget");
virtual void resume_propagation()=0
When overridden in a derived class, resumes propagation after a reservation has been released...
virtual void release_message(runtime_object_identity _MsgId)=0
When overridden in a derived class, releases a previous message reservation.
#define NULL
Definition: crtdbg.h:30
::Concurrency::details::_ReentrantPPLLock::_Scoped_lock _R_lock
A lock holder that acquires a reentrant lock on instantiation and releases it on destruction ...
Definition: agents.h:64
::Concurrency::details::_ReentrantPPLLock _M_internalLock
Internal lock used for the following synchronization:
Definition: agents.h:3895
ITarget< _Target_type > * _M_pReservedFor
Connected target that is holding a reservation
Definition: agents.h:3821
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
Reserves a message previously offered by this source_block
object.
- Parameters
-
_MsgId | The runtime_object_identity of the offered message object. |
_PTarget | A 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.
The method throws an invalid_argument exception if the parameter _PTarget is NULL
.
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.
Implements Concurrency::ISource< _TargetLinkRegistry::type::type >.
3405 if (_PTarget ==
NULL)
3407 throw std::invalid_argument(
"_PTarget");
#define NULL
Definition: crtdbg.h:30
virtual bool reserve_message(runtime_object_identity _MsgId)=0
When overridden in a derived class, reserves a message previously offered by this source_block object...
::Concurrency::details::_ReentrantPPLLock::_Scoped_lock _R_lock
A lock holder that acquires a reentrant lock on instantiation and releases it on destruction ...
Definition: agents.h:64
::Concurrency::details::_ReentrantPPLLock _M_internalLock
Internal lock used for the following synchronization:
Definition: agents.h:3895
runtime_object_identity _M_reservedId
Reserved message ID
Definition: agents.h:3827
ITarget< _Target_type > * _M_pReservedFor
Connected target that is holding a reservation
Definition: agents.h:3821
template<class _TargetLinkRegistry, class _MessageProcessorType = ordered_message_processor<typename _TargetLinkRegistry::type::type>>
When overridden in a derived class, reserves a message previously offered by this source_block
object.
- Parameters
-
_MsgId | The 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.
Implemented in Concurrency::_Join_node< _Type, _Destination_type, _Jtype >, Concurrency::_Order_node_base< _Type >, Concurrency::join< _Type, _Jtype >, Concurrency::single_assignment< _Type >, Concurrency::single_assignment< size_t >, Concurrency::timer< _Type >, Concurrency::transformer< _Input, _Output >, Concurrency::overwrite_buffer< _Type >, Concurrency::overwrite_buffer< agent_status >, and Concurrency::unbounded_buffer< _Type >.