transformer Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

A transformer messaging block is a single-target, multi-source, ordered propagator_block which can accept messages of one type and is capable of storing an unbounded number of messages of a different type.

template<class _Input, class _Output>
class transformer : public propagator_block<single_link_registry<ITarget<_Output>>,
    multi_link_registry<ISource<_Input>>>;

Parameters

_Input
The payload type of the messages accepted by the buffer.

_Output
The payload type of the messages stored and propagated out by the buffer.

Public Constructors

NameDescription
transformer::transformer ConstructorOverloaded. Constructs a transformer messaging block.
transformer::~transformer DestructorDestroys the transformer messaging block.

Protected Methods

NameDescription
transformer::accept_message MethodAccepts a message that was offered by this transformer messaging block, transferring ownership to the caller.
transformer::consume_message MethodConsumes a message previously offered by the transformer and reserved by the target, transferring ownership to the caller.
transformer::link_target_notification MethodA callback that notifies that a new target has been linked to this transformer messaging block.
transformer::propagate_message MethodAsynchronously passes a message from an ISource block to this transformer messaging block. It is invoked by the propagate method, when called by a source block.
transformer::propagate_to_any_targets MethodExecutes the transformer function on the input messages.
transformer::release_message MethodReleases a previous message reservation. (Overrides source_block::release_message.)
transformer::reserve_message MethodReserves a message previously offered by this transformer messaging block. (Overrides source_block::reserve_message.)
transformer::resume_propagation MethodResumes propagation after a reservation has been released. (Overrides source_block::resume_propagation.)
transformer::send_message MethodSynchronously passes a message from an ISource block to this transformer messaging block. It is invoked by the send method, when called by a source block.
transformer::supports_anonymous_source MethodOverrides the supports_anonymous_source method to indicate that this block can accept messages offered to it by a source that is not linked. (Overrides ITarget::supports_anonymous_source.)

For more information, see Asynchronous Message Blocks.

ISource

ITarget

source_block

propagator_block

transformer

Header: agents.h

Namespace: concurrency

Accepts a message that was offered by this transformer messaging block, transferring ownership to the caller.

virtual message<_Output>* accept_message(runtime_object_identity _MsgId);

Parameters

_MsgId
The runtime_object_identity of the offered message object.

Return Value

A pointer to the message object that the caller now has ownership of.

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

virtual message<_Output>* consume_message(runtime_object_identity _MsgId);

Parameters

_MsgId
The runtime_object_identity of the message object being consumed.

Return Value

A pointer to the message object that the caller now has ownership of.

Remarks

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

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

virtual void link_target_notification(_Inout_ ITarget<_Output> *);

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

virtual message_status propagate_message(
    _Inout_ message<_Input>* _PMessage,
    _Inout_ ISource<_Input>* _PSource);

Parameters

_PMessage
A pointer to the message object.

_PSource
A pointer to the source block offering the message.

Return Value

A message_status indication of what the target decided to do with the message.

Executes the transformer function on the input messages.

virtual void propagate_to_any_targets(_Inout_opt_ message<_Output> *);

Releases a previous message reservation.

virtual void release_message(runtime_object_identity _MsgId);

Parameters

_MsgId
The runtime_object_identity of the message object being released.

Reserves a message previously offered by this transformer messaging block.

virtual bool reserve_message(runtime_object_identity _MsgId);

Parameters

_MsgId
The runtime_object_identity of the message object being reserved.

Return Value

true if the message was successfully reserved, false otherwise.

Remarks

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

Resumes propagation after a reservation has been released.

virtual void resume_propagation();

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

virtual message_status send_message(
    _Inout_ message<_Input>* _PMessage,
    _Inout_ ISource<_Input>* _PSource);

Parameters

_PMessage
A pointer to the message object.

_PSource
A pointer to the source block offering the message.

Return Value

A message_status indication of what the target decided to do with the message.

Overrides the supports_anonymous_source method to indicate that this block can accept messages offered to it by a source that is not linked.

virtual bool supports_anonymous_source();

Return Value

true because the block does not postpone offered messages.

Constructs a transformer messaging block.

transformer(
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget = NULL);

transformer(
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget,
    filter_method const& _Filter);

transformer(
    Scheduler& _PScheduler,
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget = NULL);

transformer(
    Scheduler& _PScheduler,
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget,
    filter_method const& _Filter);

transformer(
    ScheduleGroup& _PScheduleGroup,
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget = NULL);

transformer(
    ScheduleGroup& _PScheduleGroup,
    _Transform_method const& _Func,
    _Inout_opt_ ITarget<_Output>* _PTarget,
    filter_method const& _Filter);

Parameters

_Func
A function that will be invoked for each accepted message.

_PTarget
A pointer to a target block to link with the transformer.

_Filter
A filter function which determines whether offered messages should be accepted.

_PScheduler
The Scheduler object within which the propagation task for the transformer messaging block is scheduled.

_PScheduleGroup
The ScheduleGroup object within which the propagation task for the transformer messaging block is scheduled. The Scheduler object used is implied by the schedule group.

Remarks

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

The type _Transform_method is a functor with signature _Output (_Input const &) which is invoked by this transformer messaging block to process a message.

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

Destroys the transformer messaging block.

~transformer();

concurrency Namespace
call Class

Show: