Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::ScheduledEvent Class Reference

#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 NameGetEventName () const
 

Friends

class ScheduledEventHandle
 
class EventSchedulerSystemComponent
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ScheduledEvent()

AZ::ScheduledEvent::ScheduledEvent ( const AZStd::function< void()> &  callback,
const Name eventName 
)

Constructor of ScheduledEvent class.

Parameters
callbacka call back function to be executed when the event triggers
eventNamename of the scheduled event for easier debugging

Member Function Documentation

◆ Enqueue()

void AZ::ScheduledEvent::Enqueue ( TimeMs  durationMs,
bool  autoRequeue = false 
)

Enqueue this event with the IEventScheduler.

Parameters
durationMsthe number of milliseconds to wait before triggering this scheduled event
autoRequeuetrue for running this event infinitely, false for running once

◆ GetAutoRequeue()

bool AZ::ScheduledEvent::GetAutoRequeue ( ) const

Returns whether or not auto-requeue is enabled.

Returns
true for auto re-queued, false for not auto re-queued

◆ GetEventName()

const Name & AZ::ScheduledEvent::GetEventName ( ) const

Returns the name of this scheduled event.

Returns
the name of this scheduled event

◆ GetIntervalMs()

TimeMs AZ::ScheduledEvent::GetIntervalMs ( ) const

Returns the duration this event was initially scheduled with.

Returns
TimeMs provided during event scheduling

◆ IsScheduled()

bool AZ::ScheduledEvent::IsScheduled ( ) const

Gets whether or not this scheduled event is currently scheduled for execution.

Returns
true if the scheduled event is registered with the IEventScheduler

◆ RemainingTimeInQueueMs()

TimeMs AZ::ScheduledEvent::RemainingTimeInQueueMs ( ) const

Gets the remaining time (Ms) before this event is scheduled to be triggered.

Returns
TimeMs before this event will be triggered

◆ Requeue()

void AZ::ScheduledEvent::Requeue ( TimeMs  durationMs)

ReQueue this event with a new delay.

Parameters
durationMsthe number of milliseconds to wait before triggering this scheduled event

◆ TimeInQueueMs()

TimeMs AZ::ScheduledEvent::TimeInQueueMs ( ) const

Gets the elapsed time (Ms) from when this event was inserted.

Returns
TimeMs since this scheduled event was last scheduled

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