#include <ScheduledEvent.h>
Public Member Functions | |
ScheduledEvent ()=default | |
Default constructor only for AZStd::deque compatibility. | |
ScheduledEvent (const AZStd::function< void()> &callback, const Name &eventName) | |
void | Enqueue (TimeMs durationMs, bool autoRequeue=false) |
void | Requeue () |
Requeue this scheduled event so that it triggers again. | |
void | Requeue (TimeMs durationMs) |
void | RemoveFromQueue () |
Disable auto re-queue and clear handle not to run this event. | |
bool | IsScheduled () const |
bool | GetAutoRequeue () const |
TimeMs | TimeInQueueMs () const |
TimeMs | RemainingTimeInQueueMs () const |
TimeMs | GetIntervalMs () const |
const Name & | GetEventName () const |
Friends | |
class | ScheduledEventHandle |
class | EventSchedulerSystemComponent |
The ScheduledEvent class is used to run a registered callback function at a specified execution time. Total time duration between queuing and the scheduled event triggering is not guaranteed, and will at least be quantized to frametime. This event can trigger continuously at the specified interval in ms if set with the auto-re-queue function. This event should be declared as a member of class, not in a local function as it will not trigger if it goes out of scope.
AZ::ScheduledEvent::ScheduledEvent | ( | const AZStd::function< void()> & | callback, |
const Name & | eventName | ||
) |
Constructor of ScheduledEvent class.
callback | a call back function to be executed when the event triggers |
eventName | name of the scheduled event for easier debugging |
void AZ::ScheduledEvent::Enqueue | ( | TimeMs | durationMs, |
bool | autoRequeue = false |
||
) |
Enqueue this event with the IEventScheduler.
durationMs | the number of milliseconds to wait before triggering this scheduled event |
autoRequeue | true for running this event infinitely, false for running once |
bool AZ::ScheduledEvent::GetAutoRequeue | ( | ) | const |
Returns whether or not auto-requeue is enabled.
const Name & AZ::ScheduledEvent::GetEventName | ( | ) | const |
Returns the name of this scheduled event.
TimeMs AZ::ScheduledEvent::GetIntervalMs | ( | ) | const |
Returns the duration this event was initially scheduled with.
bool AZ::ScheduledEvent::IsScheduled | ( | ) | const |
Gets whether or not this scheduled event is currently scheduled for execution.
TimeMs AZ::ScheduledEvent::RemainingTimeInQueueMs | ( | ) | const |
Gets the remaining time (Ms) before this event is scheduled to be triggered.
void AZ::ScheduledEvent::Requeue | ( | TimeMs | durationMs | ) |
ReQueue this event with a new delay.
durationMs | the number of milliseconds to wait before triggering this scheduled event |
TimeMs AZ::ScheduledEvent::TimeInQueueMs | ( | ) | const |
Gets the elapsed time (Ms) from when this event was inserted.