/// <summary>
        /// Creates a continuation that executes asynchronously when the target fiber completes.
        /// </summary>
        /// <returns>A fiber that executes when the target fiber completes.</returns>
        /// <param name="continuationCoroutine">Continuation coroutine.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <param name="continuationOptions">Continuation options.</param>
        /// <param name="scheduler">Scheduler.</param>
        public Fiber ContinueWith(IEnumerator continuationCoroutine, CancellationToken cancellationToken,
            FiberContinuationOptions continuationOptions, FiberScheduler scheduler)
        {
            if (continuationCoroutine == null)
                throw new ArgumentNullException("continuationCoroutine");

            if (scheduler == null)
                throw new ArgumentNullException("scheduler");

            var fiber = new Fiber(continuationCoroutine, cancellationToken);

            fiber.antecedent = this;
            fiber.status = (int)FiberStatus.WaitingForActivation;

            var continuation = new FiberContinuation(fiber, continuationOptions, scheduler);

            if (IsCompleted) {
                continuation.Execute();
            } else {
                // Lazy create queue
                if (continuations == null)
                    continuations = new Queue<FiberContinuation>();

                continuations.Enqueue(continuation);
            }

            return fiber;
        }
        /// <summary>
        /// Creates a continuation that executes asynchronously when the target fiber completes.
        /// </summary>
        /// <returns>A fiber that executes when the target fiber completes.</returns>
        /// <param name="continuationAction">Continuation action.</param>
        /// <param name="state">State.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <param name="continuationOptions">Continuation options.</param>
        /// <param name="scheduler">Scheduler.</param>
        public Fiber ContinueWith(Action <Fiber, object> continuationAction, object state, CancellationToken cancellationToken,
                                  FiberContinuationOptions continuationOptions, FiberScheduler scheduler)
        {
            if (continuationAction == null)
            {
                throw new ArgumentNullException("continuationAction");
            }

            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            var fiber = new Fiber((obj) => continuationAction(this, obj),
                                  state, cancellationToken);

            fiber.antecedent = this;
            fiber.status     = (int)FiberStatus.WaitingForActivation;

            var continuation = new FiberContinuation(fiber, continuationOptions, scheduler);

            if (IsCompleted)
            {
                continuation.Execute();
            }
            else
            {
                // Lazy create queue
                if (continuations == null)
                {
                    continuations = new Queue <FiberContinuation>();
                }

                continuations.Enqueue(continuation);
            }

            return(fiber);
        }