예제 #1
0
파일: NN.cs 프로젝트: zvikara/NNanomsg
        internal static void Poll(int[] s, int ct, int[] result, nn_pollfd[] info, TimeSpan?timeout)
        {
            int milliseconds = -1;

            if (timeout != null)
            {
                milliseconds = (int)timeout.Value.TotalMilliseconds;
            }
            else
            {
                milliseconds = int.MaxValue;
            }

            unsafe
            {
                for (int i = 0; i < ct; ++i)
                {
                    info[i] = new nn_pollfd {
                        fd = s[i], events = (short)Events.POLLIN, revents = 0
                    };
                }

                fixed(nn_pollfd *pInfo = info)
                {
                    Interop.nn_poll(pInfo, ct, milliseconds);
                }
            }

            for (int i = 0; i < ct; ++i)
            {
                result[i] = (info[i].revents & (short)Events.POLLIN) != 0 ? 1 : 0;
            }
        }