Exemple #1
0
 private static void Return(CoroutineWrapper wrapper)
 {
     lock (pool)
     {
         pool.Push(wrapper);
     }
 }
        internal void Initialize(ISynchronizationContext originalContext, CoroutineWrapper coroutineWrapper)
        {
            this.originalContext  = originalContext;
            this.coroutineWrapper = coroutineWrapper;

            int previousStatus = Interlocked.CompareExchange(ref status, statusInitialized, statusNone);

            if (previousStatus == statusCalled)
            {
                // awaiter has already been called -> resume
                ResumeCoroutine();
            }
        }
        public static YieldInstructionWrapper Create(YieldInstruction instruction, ISynchronizationContext originalContext, CoroutineWrapper coroutineWrapper)
        {
            var yieldWrapper = Get();

            yieldWrapper.instruction      = instruction;
            yieldWrapper.originalContext  = originalContext;
            yieldWrapper.coroutineWrapper = coroutineWrapper;
            return(yieldWrapper);
        }
Exemple #4
0
        internal void Handle(YieldInstruction yieldInstruction, ISynchronizationContext context, CoroutineWrapper wrapper)
        {
            Log("Handle yield instruction");
            var yieldWrapper = YieldInstructionWrapper.Create(yieldInstruction, context, wrapper);

            unityThread.Post(StartYieldWrapper, this, yieldWrapper);
        }
 public static CustomYieldInstruction StartCoroutine(this IThread thread, IEnumerator coroutine, CoroutineHost host)
 {
     return(CoroutineWrapper.StartCoroutine(host, thread, coroutine));
 }