TaskScheduler that can execute fibers (yieldable coroutines). Regular non-blocking tasks can also be scheduled on a FiberTaskScheduler, but YieldableTask have the distinct ability to yield execution.
Inheritance: System.Threading.Tasks.TaskScheduler, IDisposable
Example #1
0
        /// <summary>
        /// Creates a task factory using a <see cref="FiberTaskScheduler"/>
        /// initialized with the MonoBehaviour.
        /// </summary>
        /// <returns>
        /// The task factory.
        /// </returns>
        /// <param name='behaviour'>
        /// The MonoBehaviour.
        /// </param>
        public static TaskFactory CreateTaskFactory(this MonoBehaviour behaviour)
        {
            var scheduler = new FiberTaskScheduler(new UnityFiberScheduler(behaviour));

            return(new TaskFactory(scheduler.CancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler));
        }
 /// <summary>
 /// Creates a task factory using a <see cref="FiberTaskScheduler"/>
 /// initialized with the MonoBehaviour.
 /// </summary>
 /// <returns>
 /// The task factory.
 /// </returns>
 /// <param name='behaviour'>
 /// The MonoBehaviour.
 /// </param>
 public static TaskFactory CreateTaskFactory(this MonoBehaviour behaviour)
 {
     var scheduler = new FiberTaskScheduler(new UnityFiberScheduler(behaviour));
     return new TaskFactory(scheduler.CancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler);
 }
        private IEnumerator TestFuncTaskCoroutine()
        {
            var scheduler = new FiberTaskScheduler();

            var task = new YieldableTask(() => new YieldForSeconds(2));
            task.Start(scheduler);

            while (!task.IsCompleted)
                yield return FiberInstruction.YieldToAnyFiber;
        }