Beispiel #1
0
        public void Collect()
        {
            //int used = WorkerThreadReport.createdThreads();
            Interlocked.Increment(ref workUnits);

            //System.out.printf("used= %d, wi=%d\n", used, wi);
            WorkerThreadReport.RegisterWorker();
        }
Beispiel #2
0
        public static void Test()
        {
            int[] vals = new int[50000000];
            InitVals(vals);

            Test(SortSeq, vals, "Sequential sort");

            ParQuickSort sort = new ParQuickSort(LEVEL);

            Test(sort.SortTP, vals, "Threadpool sort");

            WorkerThreadReport.ShutdownWorkerThreadReport();
        }
        // Thread that monitors the worker thread's exit.
        private static void ExitMonitorThreadBody()
        {
            int rcount;

            do
            {
                List <WorkerThreadReport> exited = null;
                lock (monitor) {
                    rcount = reports.Count;
                    for (int i = 0; i < reports.Count;)
                    {
                        WorkerThreadReport r = reports[i];
                        if (!r.theThread.IsAlive)
                        {
                            reports.RemoveAt(i);
                            if (exited == null)
                            {
                                exited = new List <WorkerThreadReport>();
                            }
                            r.exitTime = Environment.TickCount;
                            exited.Add(r);
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
                if (exited != null)
                {
                    foreach (WorkerThreadReport r in exited)
                    {
                        ShowMsg("--worker #{0} exited after {1} s of inactivity",
                                r.theThreadId, (r.exitTime - r.timeOfLastUse) / 1000);
                    }
                }

                // sleep for a while.
                try {
                    Thread.Sleep(50);
                }
                catch (ThreadInterruptedException) {
                    return;
                }
            } while (true);
        }
Beispiel #4
0
 public Stats()
 {
     WorkerThreadReport.Clear();
     workUnits = 0;
 }