/// <summary> /// Extends the Task to do the passed action. The new action will /// execute on the same Thread as the rest of the Task. /// /// If the Task has already completed, or was aborted, this will /// restart the Task (on its old Thread) with the new extension. /// </summary> /// <param name="next">The next action to do.</param> /// <returns>True if the Task was still running.</returns> public bool Extend(T next) { lock ( _lock ) { InternalExtend(next); if (!isCompleted && !aborted) { return(true); } } Hikari.RequeueTask(this); return(false); }
public static void Spawn() { // Error if hikari exists if (hikari != null) { throw new Exception("Cannot spawn a second Hikari instance."); } hikari = new Hikari(); // Instantiate hikari hikari.threadManager = new ThreadManager(); hikari.unityManager = new UnityManager(); }
/// <summary> /// Spawns a dedicated thread to run the passed task. /// Once the task is completed, the Thread will be recycled. /// </summary> /// <param name="task">The task to run on the thread as it starts.</param> internal void SpawnDedicatedThread(ITask task) { System.Threading.Thread sys_thread = new System.Threading.Thread(() => { try { Thread t = new Thread(); lock (threadLock) dedicatedThreads.Add(t); t.StartTask(task); t.StartThread(); } catch (Exception e) { Hikari.ScheduleUnity((_) => { throw e; }); } }); sys_thread.IsBackground = true; sys_thread.Start(); }
/// <summary> /// Spawns a new thread and adds it to the thread pool. /// </summary> internal void SpawnThread( ) { lastThreadSpawn = DateTime.Now; numThreads++; System.Threading.Thread sys_thread = new System.Threading.Thread(() => { try { Thread t = new Thread(); lock (threadLock) threads.Add(t); t.StartThread(); } catch (Exception e) { Hikari.ScheduleUnity((_) => { throw e; }); } }); sys_thread.IsBackground = true; sys_thread.Start(); }
public static void Spawn() { // Error if hikari exists if ( hikari != null ) throw new Exception("Cannot spawn a second Hikari instance."); hikari = new Hikari(); // Instantiate hikari hikari.threadManager = new ThreadManager(); hikari.unityManager = new UnityManager(); }