void FTimerManager::InternalSetTimer(FTimerUnifiedDelegate const& InDelegate, float InRate, bool InbLoop) { // not currently threadsafe check(IsInGameThread()); // if the timer is already set, just clear it and we'll re-add it, since // there's no data to maintain. InternalClearTimer(InDelegate); if (InRate > 0.f) { // set up the new timer FTimerData NewTimerData; NewTimerData.Rate = InRate; NewTimerData.bLoop = InbLoop; NewTimerData.TimerDelegate = InDelegate; if( HasBeenTickedThisFrame() ) { NewTimerData.ExpireTime = InternalTime + InRate; NewTimerData.Status = ETimerStatus::Active; ActiveTimerHeap.HeapPush(NewTimerData); } else { // Store time remaining in ExpireTime while pending NewTimerData.ExpireTime = InRate; NewTimerData.Status = ETimerStatus::Pending; PendingTimerList.Add(NewTimerData); } } }
void FTimerManager::InternalClearTimer(FTimerHandle const& InHandle) { // not currently threadsafe check(IsInGameThread()); // Skip if the handle is invalid as it would not be found by FindTimer and unbind the current handler if it also used INDEX_NONE. if (!InHandle.IsValid()) { return; } int32 TimerIdx; FTimerData const* const TimerData = FindTimer(InHandle, &TimerIdx); if (TimerData) { InternalClearTimer(TimerIdx, TimerData->Status); } else { // Edge case. We're currently handling this timer when it got cleared. Unbind it to prevent it firing again // in case it was scheduled to fire multiple times. if (CurrentlyExecutingTimer.TimerHandle == InHandle) { CurrentlyExecutingTimer.TimerDelegate.Unbind(); CurrentlyExecutingTimer.TimerHandle.Invalidate(); } } }
void FTimerManager::InternalSetTimer(FTimerUnifiedDelegate const& InDelegate, float InRate, bool InbLoop, float InFirstDelay) { // not currently threadsafe check(IsInGameThread()); // if the timer is already set, just clear it and we'll re-add it, since // there's no data to maintain. InternalClearTimer(InDelegate); if (InRate > 0.f) { // set up the new timer FTimerData NewTimerData; NewTimerData.TimerDelegate = InDelegate; InternalSetTimer(NewTimerData, InRate, InbLoop, InFirstDelay); } }
void FTimerManager::DEPRECATED_InternalClearTimer(FTimerUnifiedDelegate const& InDelegate) { // not currently threadsafe check(IsInGameThread()); int32 TimerIdx; FTimerData const* const TimerData = DEPRECATED_FindTimer(InDelegate, &TimerIdx); if (TimerData) { InternalClearTimer(TimerIdx, TimerData->Status); } else { // Edge case. We're currently handling this timer when it got cleared. Unbind it to prevent it firing again // in case it was scheduled to fire multiple times. if (!CurrentlyExecutingTimer.TimerHandle.IsValid() && DEPRECATED_CompareUnifiedDelegates(CurrentlyExecutingTimer.TimerDelegate, InDelegate)) { CurrentlyExecutingTimer.TimerDelegate.Unbind(); } } }