/* To add new items to the list, use _kqueue_thread_push_fd().  */
static void _kqueue_thread_collect_fds(kevents *events)
/* To add new items to the list, use _kqueue_thread_push_fd().  */
static void _kqueue_thread_collect_fds(kevents *events)
{
  g_assert (events != NULL);
  gint length = 0;
  G_LOCK (pick_up_lock);
  if ((length = g_queue_get_length (&pick_up_fds_queue)) != 0)
    {
      gpointer fdp = NULL;
      kevents_extend_sz (events, length);
      while ((fdp = g_queue_pop_head (&pick_up_fds_queue)) != NULL)
        {
          struct kevent *pevent = &events->memory[events->kq_size++];
          EV_SET (pevent,
                  GPOINTER_TO_INT (fdp),
                  EVFILT_VNODE,
                  EV_ADD | EV_ENABLE | EV_ONESHOT,
                  KQUEUE_VNODE_FLAGS,
                  0,
                  0);
        }
    }
  G_UNLOCK (pick_up_lock);
}