コード例 #1
0
        public IoUringTransport(IOptions <IoUringOptions> options)
        {
            _options = (options ?? throw new ArgumentNullException(nameof(options))).Value;

            Limits.SetToMax(Resource.RLIMIT_NOFILE);

            List <int> cpus = null;

            if (_options.SetThreadAffinity)
            {
                cpus = CpuInfo.GetPreferredCpuIds(_options.ThreadCount);
            }

            var threads = new TransportThread[_options.ThreadCount];
            int cpuIdx  = 0;

            for (int i = 0; i < threads.Length; i++)
            {
                var cpuId  = cpus == null ? TransportThread.NoCpuAffinity : cpus[cpuIdx++ % cpus.Count];
                var thread = new TransportThread(_options, cpuId);
                thread.Run();
                threads[i] = thread;
            }

            TransportThreads = threads;
        }
コード例 #2
0
        private TransportThread[] CreateTransportThreads()
        {
            var threads = new TransportThread[Options.ThreadCount];

            for (int i = 0; i < threads.Length; i++)
            {
                var thread = new TransportThread(Options);
                thread.Run();
                threads[i] = thread;
            }

            return(threads);
        }
コード例 #3
0
 public void ScheduleAsyncWrite(int socket)
 {
     _asyncOperationQueue.Enqueue(TransportThread.Mask(socket, TransportThread.WritePollMask));
     Notify();
 }