Esempio n. 1
0
        /// <summary>
        /// Creates a dedicated task and a thread for it.
        ///
        /// Dedicated tasks will not relinquish control of their thread while
        /// napping, allowing them to restart immediately after napping.
        ///
        /// Once the task has completed, its thread will be recycled in Hikari
        /// and may be used for other tasks.
        ///
        /// Enumerator tasks may yield null to allow napping, or yield another
        /// Task to nap until that task finishes, then start up again.
        /// </summary>
        /// <param name="task">The enumerator to run on the new dedicated task.</param>
        /// <param name="cancel_extensions_on_abort">Whether or not to cancel extensions automatically when the Task is aborted. Defaults to true.</param>
        /// <returns>The new dedicated task.</returns>
        public static EnumeratorTask SpawnDedicatedTask(System.Collections.IEnumerator task, bool cancel_extensions_on_abort = true)
        {
            EnumeratorTask t = new EnumeratorTask(task, false, cancel_extensions_on_abort, true);

            Instance.threadManager.SpawnDedicatedThread(t);
            return(t);
        }
Esempio n. 2
0
        /// <summary>
        /// Schedules a task to be run on Unity's thread.
        ///
        /// Enumerator tasks may yield null to allow napping, or yield another
        /// Task to nap until that task finishes, then start up again.
        /// </summary>
        /// <param name="to_schedule">The enumerator to run in the task.</param>
        /// <param name="cancel_extensions_on_abort">Whether or not to cancel extensions automatically when the Task is aborted. Defaults to true.</param>
        /// <returns>The task that was added.</returns>
        public static EnumeratorTask ScheduleUnity(System.Collections.IEnumerator to_schedule, bool cancel_extensions_on_abort = true)
        {
            EnumeratorTask t = new EnumeratorTask(to_schedule, true, cancel_extensions_on_abort);

            Instance.unityManager.EnqueueTask(t);
            return(t);
        }