Never put Hikari on a GameObject! Hikari will spawn one for you. Hikari is the entry point to the threading system. It is fully threadsafe and designed to be accessed statically. To schedule a task in Hikari use the following code: Hikari.Schedule( ( ActionTask task ) => YourWorkHere(); ) To schedule a task in Unity use the following code: Hikari.ScheduleUnity( ( ActionTask task ) => YourWorkHere(); ) You may also schedule tasks using enumerators, similar to coroutines in Unity.
Inheritance: UnityEngine.MonoBehaviour
Exemple #1
0
 /// <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);
 }
Exemple #2
0
        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();
        }
Exemple #3
0
 /// <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();
 }
Exemple #4
0
 /// <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();
 }
Exemple #5
0
        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();
        }