NetMQ.Core.Ctx.ChooseIOThread C# (CSharp) Method

ChooseIOThread() private method

private ChooseIOThread ( long affinity ) : NetMQ.Core.IOThread
affinity long
return NetMQ.Core.IOThread
        public IOThread ChooseIOThread(long affinity)
        {
            if (m_ioThreads.Count == 0)
                return null;

            // Find the I/O thread with minimum load.
            int minLoad = -1;
            IOThread selectedIOThread = null;

            for (int i = 0; i != m_ioThreads.Count; i++)
            {
                var ioThread = m_ioThreads[i];

                if (affinity == 0 || (affinity & (1L << i)) > 0)
                {
                    if (selectedIOThread == null || ioThread.Load < minLoad)
                    {
                        minLoad = ioThread.Load;
                        selectedIOThread = ioThread;
                    }
                }
            }
            return selectedIOThread;
        }

Usage Example

Example #1
0
 protected IOThread ChooseIOThread(long affinity)
 {
     return(m_ctx.ChooseIOThread(affinity));
 }