| description | Learn more about: timer Class | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| title | timer Class | |||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| f1_keywords |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | 4f4dea51-de9f-40f9-93f5-dd724c567b49 |
A timer messaging block is a single-target source_block capable of sending a message to its target after a specified time period has elapsed or at specific intervals.
template<class T>
class timer : public Concurrency::details::_Timer, public source_block<single_link_registry<ITarget<T>>>;T
The payload type of the output messages of this block.
| Name | Description |
|---|---|
| timer | Overloaded. Constructs a timer messaging block that will fire a given message after a specified interval. |
| ~timer Destructor | Destroys a timer messaging block. |
| Name | Description |
|---|---|
| pause | Stops the timer messaging block. If it is a repeating timer messaging block, it can be restarted with a subsequent start() call. For non-repeating timers, this has the same effect as a stop call. |
| start | Starts the timer messaging block. The specified number of milliseconds after this is called, the specified value will be propagated downstream as a message. |
| stop | Stops the timer messaging block. |
| Name | Description |
|---|---|
| accept_message | Accepts a message that was offered by this timer messaging block, transferring ownership to the caller. |
| consume_message | Consumes a message previously offered by the timer and reserved by the target, transferring ownership to the caller. |
| link_target_notification | A callback that notifies that a new target has been linked to this timer messaging block. |
| propagate_to_any_targets | Tries to offer the message produced by the timer block to all of the linked targets. |
| release_message | Releases a previous message reservation. (Overrides source_block::release_message.) |
| reserve_message | Reserves a message previously offered by this timer messaging block. (Overrides source_block::reserve_message.) |
| resume_propagation | Resumes propagation after a reservation has been released. (Overrides source_block::resume_propagation.) |
For more information, see Asynchronous Message Blocks.
timer
Header: agents.h
Namespace: concurrency
Accepts a message that was offered by this timer messaging block, transferring ownership to the caller.
virtual message<T>* accept_message(runtime_object_identity _MsgId);_MsgId
The runtime_object_identity of the offered message object.
A pointer to the message object that the caller now has ownership of.
Consumes a message previously offered by the timer and reserved by the target, transferring ownership to the caller.
virtual message<T>* consume_message(runtime_object_identity _MsgId);_MsgId
The runtime_object_identity of the message object being consumed.
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.
A callback that notifies that a new target has been linked to this timer messaging block.
virtual void link_target_notification(_Inout_ ITarget<T>* _PTarget);_PTarget
A pointer to the newly linked target.
Stops the timer messaging block. If it is a repeating timer messaging block, it can be restarted with a subsequent start() call. For non-repeating timers, this has the same effect as a stop call.
void pause();Tries to offer the message produced by the timer block to all of the linked targets.
virtual void propagate_to_any_targets(_Inout_opt_ message<T> *);Releases a previous message reservation.
virtual void release_message(runtime_object_identity _MsgId);_MsgId
The runtime_object_identity of the message object being released.
Reserves a message previously offered by this timer messaging block.
virtual bool reserve_message(runtime_object_identity _MsgId);_MsgId
The runtime_object_identity of the message object being reserved.
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.
Resumes propagation after a reservation has been released.
virtual void resume_propagation();Starts the timer messaging block. The specified number of milliseconds after this is called, the specified value will be propagated downstream as a message.
void start();Stops the timer messaging block.
void stop();Constructs a timer messaging block that will fire a given message after a specified interval.
timer(
unsigned int _Ms,
T const& value,
ITarget<T>* _PTarget = NULL,
bool _Repeating = false);
timer(
Scheduler& _Scheduler,
unsigned int _Ms,
T const& value,
_Inout_opt_ ITarget<T>* _PTarget = NULL,
bool _Repeating = false);
timer(
ScheduleGroup& _ScheduleGroup,
unsigned int _Ms,
T const& value,
_Inout_opt_ ITarget<T>* _PTarget = NULL,
bool _Repeating = false);_Ms
The number of milliseconds that must elapse after the call to start for the specified message to be propagated downstream.
value
The value which will be propagated downstream when the timer elapses.
_PTarget
The target to which the timer will propagate its message.
_Repeating
If true, indicates that the timer will fire periodically every _Ms milliseconds.
_Scheduler
The Scheduler object within which the propagation task for the timer messaging block is scheduled is scheduled.
_ScheduleGroup
The ScheduleGroup object within which the propagation task for the timer messaging block is scheduled. The Scheduler object used is implied by the schedule group.
The runtime uses the default scheduler if you do not specify the _Scheduler or _ScheduleGroup parameters.
Destroys a timer messaging block.
~timer();