Example #1
0
        // Instructs the ThreadPool class to run the given Jibu task with the given priority and
        // synchronizing on the provided barrier.
        internal static void runTask(ThreadDelegate task, ThreadPriority priority)
        {
            JibuThread thread = JibuThreadPool.getThread();

            thread.setPriority(priority);
            thread.Task = task;
            thread.runThread();
        }
Example #2
0
 internal static void freeThreadandRelease(JibuThread t)
 {
     lock (typeof(JibuThreadPool))
     {
         if (busy.ContainsKey(t))
         {
             busy[t].Task = null;
             // used in PriParallel
             busy[t].setPriority(ThreadPriority.Normal);
             busy.Remove(t);
         }
     }
 }
Example #3
0
        // Frees a JibuThread making it avaliable to new Jibu tasks.
        // If threadqueue with that stack size exists the free thread is added.
        // Otherwise the threadqueue is created and the free thread is added.
        internal static void freeThread(JibuThread t)
        {
            JibuThread temp;

            lock (typeof(JibuThreadPool))
            {
                temp = busy[t];
                freeThreads.Push(temp);

                temp.Task = null;
                temp.setPriority(ThreadPriority.Normal);
                busy.Remove(t);
            }
        }
Example #4
0
 internal static JibuThread getThread()
 {
     lock (typeof(JibuThreadPool))
     {
         JibuThread temp;
         if (freeThreads.Count > 0)
         {
             temp = freeThreads.Pop();
         }
         else
         {
             temp = new JibuThread();
         }
         busy.Add(temp, temp);
         return(temp);
     }
 }
Example #5
0
 internal static void freeThreadandRelease(JibuThread t)
 {
     lock (typeof(JibuThreadPool))
     {
         if (busy.ContainsKey(t))
         {
             busy[t].Task = null;
             // used in PriParallel
             busy[t].setPriority(ThreadPriority.Normal);
             busy.Remove(t);
         }             
     }
 }
Example #6
0
        // Frees a JibuThread making it avaliable to new Jibu tasks.
        // If threadqueue with that stack size exists the free thread is added.
        // Otherwise the threadqueue is created and the free thread is added.
        internal static void freeThread(JibuThread t)
        {
            JibuThread temp;

            lock (typeof(JibuThreadPool))
            {
                temp = busy[t];
                freeThreads.Push(temp);

                temp.Task = null;
                temp.setPriority(ThreadPriority.Normal);
                busy.Remove(t);
            }
        }
Example #7
0
 internal static JibuThread getThread()
 {
     lock (typeof(JibuThreadPool))
     {
         JibuThread temp;
         if (freeThreads.Count > 0)
             temp = freeThreads.Pop();
         else
         {
             temp = new JibuThread();
         }
         busy.Add(temp,temp);
         return temp;              
     }                
 }