Exemple #1
0
void uv__stream_osx_select_cb(uv_async_t* handle, int status) {
  uv_stream_t* stream;
  uv__stream_select_t* s;
  int events;

  s = container_of(handle, uv__stream_select_t, async);
  stream = s->stream;

  /* Get and reset stream's events */
  uv_mutex_lock(&s->mutex);
  events = s->events;
  s->events = 0;
  uv_mutex_unlock(&s->mutex);

  /* Invoke callback on event-loop */
  if ((events & UV__IO_READ) && uv__io_active(&stream->read_watcher)) {
    uv__stream_io(stream->loop, &stream->read_watcher, UV__IO_READ);
  }
  if ((events & UV__IO_WRITE) && uv__io_active(&stream->write_watcher)) {
    uv__stream_io(stream->loop, &stream->write_watcher, UV__IO_WRITE);
  }
  if (events & UV__IO_ERROR) {
    /* XXX: Handle it! */
    uv__stream_io(stream->loop, NULL, UV__IO_ERROR);
  }
}
Exemple #2
0
void uv__stream_osx_select_cb(uv_async_t* handle, int status) {
  uv__stream_select_t* s;
  uv_stream_t* stream;
  int events;

  s = container_of(handle, uv__stream_select_t, async);
  stream = s->stream;

  /* Get and reset stream's events */
  uv_mutex_lock(&s->mutex);
  events = s->events;
  s->events = 0;
  uv_mutex_unlock(&s->mutex);

  assert(0 == (events & UV__POLLERR));

  /* Invoke callback on event-loop */
  if ((events & UV__POLLIN) && uv__io_active(&stream->io_watcher, UV__POLLIN))
    uv__stream_io(stream->loop, &stream->io_watcher, UV__POLLIN);

  if ((events & UV__POLLOUT) && uv__io_active(&stream->io_watcher, UV__POLLOUT))
    uv__stream_io(stream->loop, &stream->io_watcher, UV__POLLOUT);
}