view daemon/ThreadPoolExecutors.cs @ 34:1236da135f79

update
author riono <e165729@ie.u-ryukyu.ac.jp>
date Tue, 27 Apr 2021 22:57:14 +0900
parents 96fc5e71274e
children 61ec3dd0995c
line wrap: on
line source

using System.Threading;
using System.Threading.Tasks;
using Christie_net.codegear;

namespace Christie_net.daemon {
public class ThreadPoolExecutors {

    // TODO: どこかしらでThreadPoolの設定をする
    public ThreadPoolExecutors() {
        int nWorkerThreads;
        int nIOThreads;
        ThreadPool.GetMinThreads(out nWorkerThreads, out nIOThreads);
        ThreadPool.SetMinThreads(nWorkerThreads, nIOThreads);
    }
    
    public ThreadPoolExecutors(int nWorkerThreads, int nIOThreads) {
        ThreadPool.SetMinThreads(nWorkerThreads, nIOThreads);
    }
    
    public void Execute(CodeGearExecutor command) {
        Task.Factory.StartNew(() => command.Run());
    }
}
}