예제 #1
0
        /// <summary>
        /// A default static constructor that initializes the pool threads.
        /// </summary>
        static SmartThreadPool()
        {
            //create a scheduler for threads created outside the computation system.
            //By default this is a heap scheduller since there can be much more threads,
            //thus heap sort is more efficient.
            artificialThreadScheduler = Configuration.ArtificialThreadScheduler;

            uint physicalProcessors = Unsafe.GetPhysicalCores();

            //the idea here is {core_count} * 2 the rest should be spawned as fibers.
            ISchedulableThread[] threads = new ISchedulableThread[physicalProcessors * 2];

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new SmartThread(true, -1);
                threads[i].SchedulableIndex = i;

                if (Configuration.SmartThreadPoolPreLoadThreads)
                {
                    threads[i].Start();
                }
            }

            //Load the default thread scheduler.
            threadScheduler = Configuration.SmartPoolScheduler;

            threadScheduler.Create(threads);
        }
예제 #2
0
        static FiberPool()
        {
            ISchedulableThread[] threads = new ISchedulableThread[fiberThreadCount];

            for (int i = 0; i < fiberThreadCount; i++)
                threads[i] = new FiberThread();

            fiberScheduler = Configuration.FiberPoolScheduler;
            fiberScheduler.Create(threads);
        }
예제 #3
0
        static FiberPool()
        {
            ISchedulableThread[] threads = new ISchedulableThread[fiberThreadCount];

            for (int i = 0; i < fiberThreadCount; i++)
            {
                threads[i] = new FiberThread();
            }

            fiberScheduler = Configuration.FiberPoolScheduler;
            fiberScheduler.Create(threads);
        }
예제 #4
0
        public WinService(IThreadScheduler threadScheduler, IProcessController processController,
                          IServiceConfig serviceConfig, ISettings settings, ILog logger)
        {
            Log = logger ??
                  throw new ArgumentNullException(nameof(logger));

            FileVersionInfo fvi =
                FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);

            Log.Info($"{fvi.ProductName} v{fvi.FileVersion}");

            _threadScheduler = threadScheduler ??
                               throw new ArgumentNullException(nameof(threadScheduler));

            _processController = processController ??
                                 throw new ArgumentNullException(nameof(processController));

            _serviceConfig = serviceConfig ??
                             throw new ArgumentNullException(nameof(serviceConfig));

            _settings = settings ??
                        throw new ArgumentNullException(nameof(settings));
        }