예제 #1
0
        internal void StartTask(bool newThread)
        {
            if (cancelled)
            {
                ThrowCancelException();
            }

            if (TryReserve())
            {
                parent = Task.CurrentTask;

                if (parent != null)
                {
                    // register at our parent-task
                    parent.RegisterChild(this);
                }

                if (newThread)
                {
                    JibuThreadPool.runTask(RunTask);
                }
                else
                {
                    TaskScheduler curTaskScheduler = TaskScheduler.CurrentTaskScheduler;
                    if (curTaskScheduler == null)
                    {
                        ThreadScheduler.AddTask(this);
                    }
                    else
                    {
                        curTaskScheduler.QueuedTasks.Push(this);
                    }
                }
            }
        }
예제 #2
0
        private static void CreateTaskScheduler()
        {
            TaskScheduler ts = new TaskScheduler();

            if (last == null) // we have no TaskSchedulers
            {
                last = ts;
                // we make it point to itself
                ts.Next = ts;
            }
            else
            {
                ts.Next   = last.Next;
                last.Next = ts;
                last      = ts;
            }

            if (!queuedTasks.Empty)
            {
                StealDeque(ts);
            }

            JibuThreadPool.runTask(ts.Start);
        }
예제 #3
0
 static ThreadScheduler()
 {
     JibuThreadPool.runTask(Start);
 }