Exemple #1
0
 public static void Reset <C>(this IFiber <C> fiber)
 {
     while (fiber.Frames.Count > 0)
     {
         fiber.Done();
     }
 }
        public static IWait Done <T>(this IFiber fiber, T item)
        {
            fiber.Done();
            var wait = fiber.Wait;

            wait.Post(item);
            return(wait);
        }
Exemple #3
0
        /// <summary>
        /// Remove the frame from the stack, and satisfy the existing wait with the return value.
        /// </summary>
        public static IWait <C> Done <C, T>(this IFiber <C> fiber, T item)
        {
            // pop the stack
            fiber.Done();

            // complete the caller's wait for the return value
            fiber.Wait.Post(item);
            return(fiber.Wait);
        }
Exemple #4
0
        public static IWait <C> Fail <C>(this IFiber <C> fiber, Exception error)
        {
            // pop the stack
            fiber.Done();

            // complete the caller's wait with an exception
            fiber.Wait.Fail(error);
            return(fiber.Wait);
        }
Exemple #5
0
 public async Task <IWait> NextAsync(IFiber fiber, IItem <object> ignore)
 {
     --this.count;
     if (this.count >= 0)
     {
         return(fiber.Call <T, object>(this.rest, this.item, NextAsync));
     }
     else
     {
         return(fiber.Done(this.item));
     }
 }
 public async Task <IWait <C> > NextAsync(IFiber <C> fiber, C context, IItem <object> ignore, CancellationToken token)
 {
     --this.count;
     if (this.count >= 0)
     {
         return(fiber.Call <C, T, object>(this.rest, this.item, NextAsync));
     }
     else
     {
         return(fiber.Done(this.item));
     }
 }
Exemple #7
0
            public async Task <IWait> LoopAsync(IFiber fiber, IItem <T> item)
            {
                this.item = await item;

                --this.count;
                if (this.count >= 0)
                {
                    return(fiber.Call <T, object>(this.rest, this.item, NextAsync));
                }
                else
                {
                    return(fiber.Done(this.item));
                }
            }
Exemple #8
0
 public static IWait<C> Fail<C>(this IFiber<C> fiber, Exception error)
 {
     fiber.Done();
     fiber.Wait.Fail(error);
     return fiber.Wait;
 }
Exemple #9
0
 public static IWait<C> Done<C, T>(this IFiber<C> fiber, T item)
 {
     fiber.Done();
     fiber.Wait.Post(item);
     return fiber.Wait;
 }
Exemple #10
0
 public async Task <IWait> IdentityAsync(IFiber fiber, IItem <T> item)
 {
     return(fiber.Done(await item));
 }
Exemple #11
0
 public async Task <IWait <C> > IdentityAsync(IFiber <C> fiber, C context, IItem <T> item)
 {
     return(fiber.Done(await item));
 }
 public async Task <IWait <C> > IdentityAsync(IFiber <C> fiber, C context, IItem <T> item, CancellationToken token)
 {
     return(fiber.Done(await item));
 }