AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Protected Attributes | List of all members
alexaClientSDK::visualTimeoutManager::test::WarpTimer Class Reference

#include <MockTimerFactory.h>

Inheritance diagram for alexaClientSDK::visualTimeoutManager::test::WarpTimer:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::visualTimeoutManager::test::WarpTimer:
Collaboration graph
[legend]

Public Member Functions

bool warpForward (std::chrono::nanoseconds step)
 
std::chrono::nanoseconds getDelay ()
 
TimerDelegateInterface Functions
void start (std::chrono::nanoseconds delay, std::chrono::nanoseconds period, PeriodType periodType, size_t maxCount, std::function< void()> task) override
 
void stop () override
 
bool activate () override
 
bool isActive () const override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface
virtual ~TimerDelegateInterface ()=default
 Destructor. More...
 

Protected Attributes

std::function< void()> m_task
 
std::chrono::nanoseconds m_delay
 
bool m_active {false}
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface
enum  PeriodType { PeriodType::ABSOLUTE, PeriodType::RELATIVE }
 Specifies different ways to apply the period of a recurring task. More...
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface
static size_t getForever ()
 Static member function to get FOREVER. More...
 
- Static Public Attributes inherited from alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface
static const size_t FOREVER = 0
 

Detailed Description

A basic timer that enables jumping forward to prevent real-time waiting This timer does not support periodic delays

Member Function Documentation

◆ activate()

bool alexaClientSDK::visualTimeoutManager::test::WarpTimer::activate ( )
inlineoverridevirtual

Marks this TimerDelegateInterface as active for strict ordering purposes. When called, the implementation must atomically set the internal state as active. Functionally this method must behave as an std::atomic_exchange operation.

Returns
true if the Timer was previously inactive, else false.

Implements alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface.

◆ getDelay()

std::chrono::nanoseconds alexaClientSDK::visualTimeoutManager::test::WarpTimer::getDelay ( )
inline

Get the delay which has been configured for this timer.

Returns
The delay period

◆ isActive()

bool alexaClientSDK::visualTimeoutManager::test::WarpTimer::isActive ( ) const
inlineoverridevirtual

Reports whether the TimerDelegateInterface is active. A timer is considered active if it is waiting to start a call to the task, or if a call to the task is in progress. Examples of these can be after calls to activate() or start(). A timer is only considered inactive if it has not been started, if all requested/scheduled calls to the task have completed, or after a call to stop().

Returns
true if the Timer is active, else false.

Implements alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface.

◆ start()

void alexaClientSDK::visualTimeoutManager::test::WarpTimer::start ( std::chrono::nanoseconds  delay,
std::chrono::nanoseconds  period,
PeriodType  periodType,
size_t  maxCount,
std::function< void()>  task 
)
inlineoverridevirtual

Waits for the delay, then calls task periodically.

Parameters
delayThe non-negative time to wait before making the first task call.
periodThe non-negative time to wait between subsequent task calls.
periodTypeThe type of period to use when making subsequent task calls.
maxCountThe desired number of times to call task. TimerDelegateInterface::getForever() means to call forever until stop() is called. Note that fewer than maxCount calls may occur if periodType is PeriodType::ABSOLUTE and the task runtime exceeds period.
taskA callable type representing a task.

Implements alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface.

◆ stop()

void alexaClientSDK::visualTimeoutManager::test::WarpTimer::stop ( )
inlineoverridevirtual

Stops the TimerDelegateInterface (if running). This should not interrupt an active call to the task, but will prevent any subequent calls to the task. If stop() is called while the task is executing, this function will block until the task completes.

Note
In the special case that stop() is called from inside the task function, stop() will still prevent any subsequent calls to the task, but will not block as described above.

Implements alexaClientSDK::avsCommon::sdkInterfaces::timing::TimerDelegateInterface.

◆ warpForward()

bool alexaClientSDK::visualTimeoutManager::test::WarpTimer::warpForward ( std::chrono::nanoseconds  step)
inline

Simulate time moving forward by the given period, if step is greater than the configured delay the timer will be fired. Step time is absolute, time is not added to any previous calls to this function.

Parameters
stepTime period to step forward.
Returns
True if task was dispatched

Member Data Documentation

◆ m_active

bool alexaClientSDK::visualTimeoutManager::test::WarpTimer::m_active {false}
protected

◆ m_delay

std::chrono::nanoseconds alexaClientSDK::visualTimeoutManager::test::WarpTimer::m_delay
protected

◆ m_task

std::function<void()> alexaClientSDK::visualTimeoutManager::test::WarpTimer::m_task
protected

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

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0