Exemple #1
0
        /**
         * Notifies every registered listener that a task execution has successfully
         * completed.
         *
         * @param executor
         *            The task executor.
         */
        internal void notifyTaskSucceeded(TaskExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor", "executor is null.");
            }

            lock (listeners)
            {
                int size = listeners.Count;
                for (int i = 0; i < size; i++)
                {
                    SchedulerListener l = (SchedulerListener)listeners[i];
                    l.TaskSucceeded(executor);
                }
            }
        }
Exemple #2
0
        /**
         * It waits until the given task executor is dead. It is similar to
         * {@link TaskExecutor#join()}, but this one avoids
         * {@link ThreadInterruptedException} instances.
         *
         * @param executor
         *            The task executor.
         */
        private void tillExecutorDies(TaskExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor", "executor is null.");
            }

            bool dead = false;

            do
            {
                try
                {
                    executor.Join();
                    dead = true;
                }
                catch (ThreadInterruptedException e)
                {
                    ;
                }
            } while (!dead);
        }
Exemple #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="executor"></param>
 public MyContext(TaskExecutor executor)
 {
     this.cTaskExecutor = executor;
 }
Exemple #4
0
 /**
  * Builds the executor.
  * 
  * @param scheduler
  *            The scheduler whose this executor belongs to.
  * @param task
  *            The task that has to be executed.
  */
 internal TaskExecutor(Scheduler scheduler, Task task)
 {
     this.scheduler = scheduler;
     this.task = task;
     this.context = new MyContext(this);
     this.myself = this;
 }
Exemple #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="executor"></param>
 public Runner(TaskExecutor executor)
 {
     this.cTaskExecutor = executor;
 }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="executor"></param>
 public Runner(TaskExecutor executor)
 {
     this.cTaskExecutor = executor;
 }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="executor"></param>
 public MyContext(TaskExecutor executor)
 {
     this.cTaskExecutor = executor;
 }
Exemple #8
0
 /**
  * It waits until the given task executor is dead. It is similar to
  * {@link TaskExecutor#join()}, but this one avoids
  * {@link ThreadInterruptedException} instances.
  * 
  * @param executor
  *            The task executor.
  */
 private void tillExecutorDies(TaskExecutor executor)
 {
     if (executor == null)
         throw new ArgumentNullException("executor", "executor is null.");
     
     bool dead = false;
     do
     {
         try
         {
             executor.Join();
             dead = true;
         }
         catch (ThreadInterruptedException e)
         {
             ;
         }
     } while (!dead);
 }
Exemple #9
0
 /**
  * Notifies every registered listener that a task execution has failed due
  * to an uncaught exception.
  * 
  * @param executor
  *            The task executor.
  * @param exception
  *            The exception.
  */
 internal void notifyTaskFailed(TaskExecutor executor, ThrowableException exception)
 {
     if (executor == null)
         throw new ArgumentNullException("executor", "executor is null.");
     if (exception == null)
         throw new ArgumentNullException("exception", "exception is null.");
     
     lock (listeners)
     {
         int size = listeners.Count;
         if (size > 0)
         {
             for (int i = 0; i < size; i++)
             {
                 SchedulerListener l = (SchedulerListener)listeners[i];
                 l.TaskFailed(executor, exception);
             }
         }
         else
         {
             // Logs on console if no one has been notified about it.
             Console.WriteLine(exception.ToString());
         }
     }
 }
Exemple #10
0
 /**
  * Notifies every registered listener that a task execution has successfully
  * completed.
  * 
  * @param executor
  *            The task executor.
  */
 internal void notifyTaskSucceeded(TaskExecutor executor)
 {
     if (executor == null)
         throw new ArgumentNullException("executor", "executor is null.");
     
     lock (listeners)
     {
         int size = listeners.Count;
         for (int i = 0; i < size; i++)
         {
             SchedulerListener l = (SchedulerListener)listeners[i];
             l.TaskSucceeded(executor);
         }
     }
 }
Exemple #11
0
 /**
  * This method is called by a task executor to notify that the execution is
  * completed.
  * 
  * @param executor
  *            The executor which has completed its task.
  */
 internal void notifyExecutorCompleted(TaskExecutor executor)
 {
     if (executor == null)
         throw new ArgumentNullException("executor", "executor is null.");
     
     lock (executors)
     {
         executors.Remove(executor);
     }
 }
Exemple #12
0
 /**
  * Starts the given task within a task executor.
  * 
  * @param task
  *            The task.
  * @return The spawned task executor.
  */
 internal TaskExecutor spawnExecutor(Task task)
 {
     if (task == null)
         throw new ArgumentNullException("task", "task is null.");
     
     TaskExecutor e = new TaskExecutor(this, task);
     lock (executors)
     {
         executors.Add(e);
     }
     e.Start(daemon);
     return e;
 }