Beispiel #1
0
 private int TaskEntry(TaskScheduler.ThreadContext ti, TaskScheduler.PlanItem pi)
 {
     // TODO: remove this method , replace that routing to task registration
     QueueTask task = pi as QueueTask;
     switch (task.Module.Role)
     {
         case ExecutionType.Consumer:
             return ConsumerEntry(task);
             break;
         case ExecutionType.Producer:
             return ProducerEntry(task);
             break;
     }
     return 1;
 }
Beispiel #2
0
        public void CreateIsolatedThreadForPlan(PlanItem pi)
        {
            if (pi.intervalType == IntervalType.isolatedThread)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(IsolatedThreadEntry));
                thread.Name = "TaskScheduler IsolatedThread#" + threads.Count.ToString() + " (" + pi.NameAndDescription + ")";
                ThreadContext ti = new ThreadContext()
                {
                    hThread  = thread,
                    rootPlan = plan,
                    Job      = pi,
                    Isolated = true
                };

                thread.Start(ti);
                threads.Add(ti);
            }
        }
Beispiel #3
0
        private int TaskEntry(TaskScheduler.ThreadContext ti, TaskScheduler.PlanItem pi)
        {
            QueueTask task = pi as QueueTask;

            switch (task.Module.Role)
            {
            case ExecutionType.Consumer:
                return(ConsumerEntry(task));

                break;

            case ExecutionType.Producer:
                return(ProducerEntry(task));

                break;
            }
            return(1);
        }
Beispiel #4
0
 private int IsolatedTaskEntry(TaskScheduler.ThreadContext ti, TaskScheduler.PlanItem pi)
 {
     QueueTask task = pi as QueueTask;
     try
     {
         ((IModIsolatedProducer)task.Module.MI).IsolatedProducer(task.Parameters);
     }
     catch (Exception e)
     {
         logger.Exception(e, "isolated call procedure", "module '{0}' will be turned off", task.ModuleName);
         ti.StopThread = true;
     }
     //task.Module.Producer(task.Parameters);
     while (!ti.StopThread)
     {
         System.Threading.Thread.Sleep(100);
     }
     ((IModIsolatedProducer)task.Module.MI).IsolatedProducerStop();
     return 1;
 }
Beispiel #5
0
        /// <summary>
        /// Pull next job from execution plan
        /// </summary>
        /// <param name="ti"></param>
        static void IntermediateThread(ThreadContext ti)
        {
            PlanItem nextJob;

            if (ti.Job != null)
            {
                ti.Job.ExucutingNow = false;
            }

            nextJob = ti.rootPlan.Next(true);

            ti.Job = nextJob;
        }
Beispiel #6
0
 static void ExitThread(ThreadContext ti)
 {
     ti.StoppedThread = true;
     //Console.WriteLine("Exit" + ti.ManagedID);
 }
Beispiel #7
0
        //public void Allocate()
        public void Revoke()
        {
            if (threads.Count > 0)
            {
                for (int i = 0; i < threads.Count; i++)
                {
                    if (threads[i].StoppedThread)
                    {
                        threads[i].StopThread = false;
                        threads[i].StoppedThread = false;

                        if (!threads[i].hThread.IsAlive)
                            threads.RemoveAt(i--);
                    }
                }
            }

            for (int i = 0; threads.Count < maxThreads; i++)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(ThreadEntry));
                thread.Name = "TaskScheduler Thread#" + i.ToString();
                ThreadContext ti = new ThreadContext()
                {
                    hThread = thread,
                    rootPlan = plan
                };

                thread.Start(ti);
                threads.Add(ti);
            }
        }
Beispiel #8
0
        public void CreateIsolatedThreadForPlan(PlanItem pi)
        {
            if (pi.intervalType == IntervalType.isolatedThread)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(IsolatedThreadEntry));
                thread.Name = "TaskScheduler IsolatedThread#" + pi.NameAndDescription;
                ThreadContext ti = new ThreadContext()
                {
                    hThread = thread,
                    rootPlan = plan,
                    Job = pi,
                    Isolated = true
                };

                thread.Start(ti);
                threads.Add(ti);
            }
        }
Beispiel #9
0
 static void ExitThread(ThreadContext ti)
 {
     ti.StoppedThread = true;
     //Console.WriteLine("Exit" + ti.ManagedID);
 }