Esempio n. 1
0
int
thread_wait_cond (void *event, dk_mutex_t *holds, TVAL timeout)
{
  int rc;

  if (holds)
    {
      mutex_leave (holds);
      rc = _fiber_sleep (event, timeout);
      mutex_enter (holds);
    }
  else
    rc = _fiber_sleep (event, timeout);

  return rc;
}
Esempio n. 2
0
int
thread_select (int n, fd_set *rfds, fd_set *wfds, void *event, TVAL timeout)
{
  thread_t *thr = _current_fiber;

  if (rfds)
    thr->thr_rfds = *rfds;
  else
    FD_ZERO (&thr->thr_rfds);

  if (wfds)
    thr->thr_wfds = *wfds;
  else
    FD_ZERO (&thr->thr_wfds);
  thr->thr_nfds = n;

  /* Signalled in _fiber_event_loop () */
  if (_fiber_sleep (event, timeout) == -1)
    {
      thr->thr_nfds = 0;
      return 0;
    }

  thr->thr_nfds = 0;
  if (rfds)
    *rfds = thr->thr_rfds;
  if (wfds)
    *wfds = thr->thr_wfds;

  return thr->thr_retcode;
}
Esempio n. 3
0
void
thread_sleep (TVAL timeout)
{
  _fiber_sleep (NULL, timeout);
  thr_errno = 0;
}