コード例 #1
0
 public static void Subscribe <T>(
     this Schedulable <T> schedulable,
     IScheduler scheduler,
     Action <T> onCompleted,
     Action <Exception> onError)
 {
     schedulable.ContinueWith(scheduler, onCompleted);
     TaskChain.Schedule(schedulable.GetRoot(), onError);
 }
コード例 #2
0
            public void Enqueue(TaskChain item)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(_ =>
                {
                    if (item == null)
                    {
                        return;
                    }

                    while (true)
                    {
                        var status = item.Next();
                        if (status != ExecutionStatus.Continue)
                        {
                            break;
                        }
                    }
                });
            }
コード例 #3
0
        public static TaskChain Schedule(ISchedulable schedulable, Action <Exception> onError)
        {
            var item = new TaskChain
            {
                Enumerator = schedulable.Traverse().GetEnumerator(),
                OnError    = onError
            };

            if (item.Enumerator.MoveNext())
            {
                if (item.Enumerator.Current.Scheduler == null)
                {
                    // default
                    Scheduler.MainThread.Enqueue(item);
                }
                else
                {
                    item.Enumerator.Current.Scheduler.Enqueue(item);
                }
            }

            return(item);
        }
コード例 #4
0
            public void Enqueue(TaskChain item)
            {
                var q = GetQueue();

                if (q == null)
                {
                    q = new Queue <TaskChain>(5);
                    q.Enqueue(item);
                    SetQueue(q);

                    try
                    {
                        Trampoline.Run(q);
                    }
                    finally
                    {
                        SetQueue(null);
                    }
                }
                else
                {
                    q.Enqueue(item);
                }
            }
コード例 #5
0
 public void Enqueue(TaskChain item)
 {
     m_queue.Enqueue(item);
 }