using System.Collections.Generic;

namespace pdinklag
{
    /// <summary>
    /// Represents a coroutine execution context.
    /// </summary>
    public interface IContext
    {
        /// <summary>
        /// Starts the execution of the given coroutines and waits for all of them to finish.
        /// </summary>
        /// <param name="coroutines">the coroutines to execute in parallel</param>
        /// <returns>the corresponding yield instruction</returns>
        YieldInstructionCode Join(InlineArray<IEnumerator<YieldInstructionCode>> coroutines);

        /// <summary>
        /// Starts the execution of the given coroutines and waits for all them to finish.
        /// </summary>
        /// <param name="yields">the instructions to yield in parallel</param>
        /// <returns>the corresponding yield instruction</returns>
        YieldInstructionCode Join(InlineArray<YieldInstructionCode> yields);

        YieldInstructionCode Join(YieldInstructionCode yield1, YieldInstructionCode yield2);
        YieldInstructionCode Join(YieldInstructionCode yield1, YieldInstructionCode yield2, YieldInstructionCode yield3);
        YieldInstructionCode Join(YieldInstructionCode yield1, YieldInstructionCode yield2, YieldInstructionCode yield3, YieldInstructionCode yield4);

        /// <summary>
        /// Waits for a coroutine to finish.
        /// </summary>
        /// <param name="coroutine">the coroutine to wait for</param>
        /// <returns>the corresponding yield instruction</returns>
        YieldInstructionCode WaitUntilDone(IEnumerator<YieldInstructionCode> coroutine);
    }
}
