private void addSchedulerAction(SchedulerAction schedulerAction) { actions.Add(schedulerAction); if (updateNextAction(schedulerAction)) { RuntimeContext.onNextScheduleModified(); } }
public virtual void reset() { lock (this) { actions = new LinkedList <SchedulerAction>(); nextAction = null; } }
/// <summary> /// Add a new action to the Scheduler. /// This method has to be thread-safe. /// </summary> /// <param name="schedule"> microTime when the action has to be executed. 0 for now. </param> /// <param name="action"> action to be executed on the defined schedule. </param> public virtual void addAction(long schedule, IAction action) { lock (this) { SchedulerAction schedulerAction = new SchedulerAction(schedule, action); addSchedulerAction(schedulerAction); } }
private bool updateNextAction(SchedulerAction schedulerAction) { if (nextAction == null || schedulerAction.Schedule < nextAction.Schedule) { nextAction = schedulerAction; return(true); } return(false); }
private void updateNextAction() { nextAction = null; for (IEnumerator <SchedulerAction> it = actions.GetEnumerator(); it.MoveNext();) { SchedulerAction schedulerAction = it.Current; updateNextAction(schedulerAction); } RuntimeContext.onNextScheduleModified(); }
public virtual void removeAction(long schedule, IAction action) { lock (this) { //JAVA TO C# CONVERTER WARNING: Unlike Java's ListIterator, enumerators in .NET do not allow altering the collection: for (IEnumerator <SchedulerAction> lit = actions.GetEnumerator(); lit.MoveNext();) { SchedulerAction schedulerAction = lit.Current; if (schedulerAction.Schedule == schedule && schedulerAction.Action == action) { //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: lit.remove(); updateNextAction(); break; } } } }