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

            return(false);
        }
Ejemplo n.º 5
0
        private void updateNextAction()
        {
            nextAction = null;

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

            RuntimeContext.onNextScheduleModified();
        }
Ejemplo n.º 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;
                    }
                }
            }
        }