UnityFiberExtensions.cs
Go to the documentation of this file.
1 using System;
2 using UnityEngine;
3 
4 namespace SpicyPixel.Threading
5 {
9  public static class UnityFiberExtensions
10  {
16  public static Coroutine GetAsUnityCoroutine(this Fiber fiber)
17  {
18  object coroutine;
19  if (fiber.Properties.TryGetValue(UnityFiberScheduler.UnityCoroutineKey, out coroutine))
20  return coroutine as Coroutine;
21 
22  throw new InvalidOperationException("You must start the Fiber on a scheduler that allows inlining "
23  + "or otherwise wait for it to start before yielding against it as a Unity Coroutine. "
24  + " Fiber coroutines can directly yield to other Fibers without this restriction.");
25  }
26  }
27 }
28 
A Fiber is a lightweight means of scheduling work that enables multiple units of processing to execut...
IDictionary< string, object > Properties
Gets user-defined properties associated with the fiber.
Definition: Fiber.cs:150
FiberScheduler that can execute fibers (yieldable coroutines) during the update cycle of a MonoBehavi...
static Coroutine GetAsUnityCoroutine(this Fiber fiber)
Gets the fiber as a Unity coroutine that can be yielded against.