Ejemplo n.º 1
0
        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;
            }
        }