// 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(); }
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); } } }
// 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); } }
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); } }
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; } }