public void UpdateScheduledEvents() { try { this.m_TransactionMode = true; long num = Panel.TimeSinceStartupMs(); int count = this.m_ScheduledItems.Count; long num2 = num + 20L; int num3 = this.m_LastUpdatedIndex + 1; if (num3 >= count) { num3 = 0; } for (int i = 0; i < count; i++) { num = Panel.TimeSinceStartupMs(); if (!this.disableThrottling && num >= num2) { break; } int num4 = num3 + i; if (num4 >= count) { num4 -= count; } ScheduledItem scheduledItem = this.m_ScheduledItems[num4]; if (num - scheduledItem.delayMs >= scheduledItem.startMs) { TimerState state = new TimerState { start = scheduledItem.startMs, now = num }; scheduledItem.PerformTimerUpdate(state); scheduledItem.startMs = num; scheduledItem.delayMs = scheduledItem.intervalMs; if (scheduledItem.ShouldUnschedule()) { this.Unschedule(scheduledItem); } } this.m_LastUpdatedIndex = num4; } } finally { this.m_TransactionMode = false; for (int j = 0; j < this.m_UnscheduleTransactions.Count; j++) { this.Unschedule(this.m_UnscheduleTransactions[j]); } this.m_UnscheduleTransactions.Clear(); for (int k = 0; k < this.m_ScheduleTransactions.Count; k++) { this.Schedule(this.m_ScheduleTransactions[k]); } this.m_ScheduleTransactions.Clear(); } }
public void UpdateScheduledEvents() { try { this.m_TransactionMode = true; long num = (long)(Time.realtimeSinceStartup * 1000f); int count = this.m_ScheduledItems.Count; int num2 = this.m_LastUpdatedIndex + 1; if (num2 >= count) { num2 = 0; } for (int i = 0; i < count; i++) { int num3 = num2 + i; if (num3 >= count) { num3 -= count; } ScheduledItem scheduledItem = this.m_ScheduledItems[num3]; if (num - scheduledItem.delayMs >= scheduledItem.startMs) { TimerState state = new TimerState { start = scheduledItem.startMs, now = num }; scheduledItem.PerformTimerUpdate(state); scheduledItem.startMs = num; scheduledItem.delayMs = scheduledItem.intervalMs; if (scheduledItem.ShouldUnschedule()) { this.Unschedule(scheduledItem); } } this.m_LastUpdatedIndex = num3; } } finally { this.m_TransactionMode = false; for (int j = 0; j < this.m_UnscheduleTransactions.Count; j++) { this.Unschedule(this.m_UnscheduleTransactions[j]); } this.m_UnscheduleTransactions.Clear(); for (int k = 0; k < this.m_ScheduleTransactions.Count; k++) { this.Schedule(this.m_ScheduleTransactions[k]); } this.m_ScheduleTransactions.Clear(); } }
public void UpdateScheduledEvents() { try { m_TransactionMode = true; // TODO: On a GAME Panel game time should be per frame and not change during a frame. // TODO: On an Editor Panel time should be real time long currentTime = Panel.TimeSinceStartupMs(); int itemsCount = m_ScheduledItems.Count; const long maxMsPerUpdate = 20; long maxTime = currentTime + maxMsPerUpdate; int startIndex = m_LastUpdatedIndex + 1; if (startIndex >= itemsCount) { startIndex = 0; } for (int i = 0; i < itemsCount; i++) { currentTime = Panel.TimeSinceStartupMs(); if (!disableThrottling && currentTime >= maxTime) { //We spent too much time on this frame updating items, we break for now, we'll resume next frame break; } int index = startIndex + i; if (index >= itemsCount) { index -= itemsCount; } ScheduledItem scheduledItem = m_ScheduledItems[index]; if (currentTime - scheduledItem.delayMs >= scheduledItem.startMs) { TimerState timerState = new TimerState { start = scheduledItem.startMs, now = currentTime }; if (!m_UnscheduleTransactions.Contains(scheduledItem)) // Don't execute items that have been amrker for future removal { scheduledItem.PerformTimerUpdate(timerState); } scheduledItem.startMs = currentTime; scheduledItem.delayMs = scheduledItem.intervalMs; if (scheduledItem.ShouldUnschedule() && !m_UnscheduleTransactions.Contains(scheduledItem)) // if the scheduledItem has been unscheduled explicitly in PerformTimerUpdate then it will be in m_UnscheduleTransactions and we shouldn't // unschedule it again { Unschedule(scheduledItem); } } m_LastUpdatedIndex = index; } } finally { m_TransactionMode = false; // Rule: remove unscheduled transactions first foreach (var item in m_UnscheduleTransactions) { PrivateUnSchedule(item); } m_UnscheduleTransactions.Clear(); // Then add scheduled transactions foreach (var item in m_ScheduleTransactions) { Schedule(item); } m_ScheduleTransactions.Clear(); } }
public void UpdateScheduledEvents() { try { m_TransactionMode = true; // TODO: On a GAME Panel game time should be per frame and not change during a frame. // TODO: On an Editor Panel time should be real time long currentTime = Panel.TimeSinceStartupMs(); int itemsCount = m_ScheduledItems.Count; const long maxMsPerUpdate = 20; long maxTime = currentTime + maxMsPerUpdate; int startIndex = m_LastUpdatedIndex + 1; if (startIndex >= itemsCount) { startIndex = 0; } for (int i = 0; i < itemsCount; i++) { currentTime = Panel.TimeSinceStartupMs(); if (!disableThrottling && currentTime >= maxTime) { //We spent too much time on this frame updating items, we break for now, we'll resume next frame break; } int index = startIndex + i; if (index >= itemsCount) { index -= itemsCount; } ScheduledItem scheduledItem = m_ScheduledItems[index]; if (currentTime - scheduledItem.delayMs >= scheduledItem.startMs) { TimerState timerState = new TimerState { start = scheduledItem.startMs, now = currentTime }; scheduledItem.PerformTimerUpdate(timerState); scheduledItem.startMs = currentTime; scheduledItem.delayMs = scheduledItem.intervalMs; if (scheduledItem.ShouldUnschedule()) { Unschedule(scheduledItem); } } m_LastUpdatedIndex = index; } } finally { m_TransactionMode = false; // Rule: remove unscheduled transactions first for (int s = 0; s < m_UnscheduleTransactions.Count; s++) { Unschedule(m_UnscheduleTransactions[s]); } m_UnscheduleTransactions.Clear(); // Then add scheduled transactions for (int s = 0; s < m_ScheduleTransactions.Count; s++) { Schedule(m_ScheduleTransactions[s]); } m_ScheduleTransactions.Clear(); } }