示例#1
0
 private void addSchedulerAction(SchedulerAction schedulerAction)
 {
     actions.Add(schedulerAction);
     if (updateNextAction(schedulerAction))
     {
         RuntimeContext.onNextScheduleModified();
     }
 }
示例#2
0
 public virtual void reset()
 {
     lock (this)
     {
         actions    = new LinkedList <SchedulerAction>();
         nextAction = null;
     }
 }
示例#3
0
 /// <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);
     }
 }
示例#4
0
        private bool updateNextAction(SchedulerAction schedulerAction)
        {
            if (nextAction == null || schedulerAction.Schedule < nextAction.Schedule)
            {
                nextAction = schedulerAction;
                return(true);
            }

            return(false);
        }
示例#5
0
        private void updateNextAction()
        {
            nextAction = null;

            for (IEnumerator <SchedulerAction> it = actions.GetEnumerator(); it.MoveNext();)
            {
                SchedulerAction schedulerAction = it.Current;
                updateNextAction(schedulerAction);
            }

            RuntimeContext.onNextScheduleModified();
        }
示例#6
0
        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;
                    }
                }
            }
        }