public void HeliosBenchmark(IThreadPool <IThreadPoolWorkItem> pool, Counts counts)
 {
     using (var mre = new CountdownEvent(1))
     {
         var workItem = new RemainingWorkItem(mre, counts.Items);
         for (long i = 0; i < counts.Items; i++)
         {
             pool.UnsafeQueueUserWorkItem(workItem, false);
         }
         mre.Wait();
     }
 }
        public void Sequential_03_Overload(IThreadPool <IThreadPoolWorkItem> pool, Counts counts)
        {
            using var countdown = new CountdownEvent((int)counts.Iterations);

            for (var i = 0; i < counts.Iterations; i++)
            {
                var workItem = new SequentialWorkItem(pool, countdown, counts.Items);
                pool.UnsafeQueueUserWorkItem(workItem, false);
            }

            countdown.Wait();
            DrainQueues(pool);
        }
        public void Local_02_FullLoad(IThreadPool <IThreadPoolWorkItem> pool, Counts counts)
        {
            for (var j = 0; j < counts.Iterations; j++)
            {
                using var countdown = new CountdownEvent((int)counts.Items);
                var feedJobs = new FeedJobsWorkItem(pool, countdown, counts.NestedItems, local: true);

                for (var i = 0; i < counts.Items; i++)
                {
                    pool.UnsafeQueueUserWorkItem(feedJobs, false);
                }

                countdown.Wait();
            }

            DrainQueues(pool);
        }
        public void Global_02_FullLoad(IThreadPool <IThreadPoolWorkItem> pool, Counts counts)
        {
            for (var j = 0; j < counts.Iterations; j++)
            {
                using var countdown = new CountdownEvent(1);
                var remaining = new RemainingWorkItem(countdown, counts.Items);

                for (var i = 0; i < counts.Items; i++)
                {
                    pool.UnsafeQueueUserWorkItem(remaining, false);
                }

                countdown.Wait();
            }

            DrainQueues(pool);
        }
        public void Global_01_PartialLoad(IThreadPool <IThreadPoolWorkItem> pool, Counts counts)
        {
            for (var j = 0; j < counts.Iterations; j++)
            {
                using var countdown = new CountdownEvent(1);
                var signal = new RemainingWorkItem(countdown, counts.Items);

                for (var i = 0; i < counts.Items; i++)
                {
                    pool.UnsafeQueueUserWorkItem(signal, false);
                }

                countdown.Wait();
            }

            // TODO: Item adding is single threaded here
            DrainQueues(pool);
        }