您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uv__update_time函数代码示例

51自学网 2021-06-03 09:27:24
  C++
这篇教程C++ uv__update_time函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uv__update_time函数的典型用法代码示例。如果您正苦于以下问题:C++ uv__update_time函数的具体用法?C++ uv__update_time怎么用?C++ uv__update_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uv__update_time函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: uv_run

int uv_run(uv_loop_t* loop, uv_run_mode mode) {  int timeout;  int r;  r = uv__loop_alive(loop);  if (!r)    uv__update_time(loop);  while (r != 0 && loop->stop_flag == 0) {    UV_TICK_START(loop, mode);    uv__update_time(loop);    uv__run_timers(loop);    uv__run_pending(loop);    uv__run_idle(loop);    uv__run_prepare(loop);    timeout = 0;    if ((mode & UV_RUN_NOWAIT) == 0)      timeout = uv_backend_timeout(loop);    uv__io_poll(loop, timeout);    uv__run_check(loop);    uv__run_closing_handles(loop);    if (mode == UV_RUN_ONCE) {      /* UV_RUN_ONCE implies forward progess: at least one callback must have       * been invoked when it returns. uv__io_poll() can return without doing       * I/O (meaning: no callbacks) when its timeout expires - which means we       * have pending timers that satisfy the forward progress constraint.       *       * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from       * the check.       */      uv__update_time(loop);      uv__run_timers(loop);    }    r = uv__loop_alive(loop);    UV_TICK_STOP(loop, mode);    if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT))      break;  }  /* The if statement lets gcc compile it to a conditional store. Avoids   * dirtying a cache line.   */  if (loop->stop_flag != 0)    loop->stop_flag = 0;  return r;}
开发者ID:7designstudios,项目名称:node,代码行数:53,


示例2: uv_loop_init

int uv_loop_init(uv_loop_t* loop) {  int err;  uv__signal_global_once_init();  memset(loop, 0, sizeof(*loop));  heap_init((struct heap*) &loop->timer_heap);  QUEUE_INIT(&loop->wq);  QUEUE_INIT(&loop->active_reqs);  QUEUE_INIT(&loop->idle_handles);  QUEUE_INIT(&loop->async_handles);  QUEUE_INIT(&loop->check_handles);  QUEUE_INIT(&loop->prepare_handles);  QUEUE_INIT(&loop->handle_queue);  loop->nfds = 0;  loop->watchers = NULL;  loop->nwatchers = 0;  QUEUE_INIT(&loop->pending_queue);  QUEUE_INIT(&loop->watcher_queue);  loop->closing_handles = NULL;  uv__update_time(loop);  uv__async_init(&loop->async_watcher);  loop->signal_pipefd[0] = -1;  loop->signal_pipefd[1] = -1;  loop->backend_fd = -1;  loop->emfile_fd = -1;  loop->timer_counter = 0;  loop->stop_flag = 0;  err = uv__platform_loop_init(loop);  if (err)    return err;  uv_signal_init(loop, &loop->child_watcher);  uv__handle_unref(&loop->child_watcher);  loop->child_watcher.flags |= UV__HANDLE_INTERNAL;  QUEUE_INIT(&loop->process_handles);  if (uv_rwlock_init(&loop->cloexec_lock))    abort();  if (uv_mutex_init(&loop->wq_mutex))    abort();  if (uv_async_init(loop, &loop->wq_async, uv__work_done))    abort();  uv__handle_unref(&loop->wq_async);  loop->wq_async.flags |= UV__HANDLE_INTERNAL;  return 0;}
开发者ID:Muraad,项目名称:harmony,代码行数:55,


示例3: uv_run2

int uv_run2(uv_loop_t* loop, uv_run_mode mode) {  int r;  if (!uv__loop_alive(loop))    return 0;  do {    uv__update_time(loop);    uv__run_timers(loop);    uv__run_idle(loop);    uv__run_prepare(loop);    uv__run_pending(loop);    uv__io_poll(loop, (mode & UV_RUN_NOWAIT ? 0 : uv_backend_timeout(loop)));    uv__run_check(loop);    uv__run_closing_handles(loop);    r = uv__loop_alive(loop);  } while (r && !(mode & (UV_RUN_ONCE | UV_RUN_NOWAIT)));  return r;}
开发者ID:anguskwan,项目名称:libuv,代码行数:20,


示例4: uv_run

int uv_run(uv_loop_t* loop, uv_run_mode mode) {  int timeout;  int r;  r = uv__loop_alive(loop);  while (r != 0 && loop->stop_flag == 0) {    UV_TICK_START(loop, mode);    uv__update_time(loop);    uv__run_timers(loop);    uv__run_idle(loop);    uv__run_prepare(loop);    uv__run_pending(loop);    timeout = 0;    if ((mode & UV_RUN_NOWAIT) == 0)      timeout = uv_backend_timeout(loop);    uv__io_poll(loop, timeout);    uv__run_check(loop);    uv__run_closing_handles(loop);    r = uv__loop_alive(loop);    UV_TICK_STOP(loop, mode);    if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT))      break;  }  /* The if statement lets gcc compile it to a conditional store. Avoids   * dirtying a cache line.   */  if (loop->stop_flag != 0)    loop->stop_flag = 0;  return r;}
开发者ID:Cycle-Applications,项目名称:node,代码行数:37,


示例5: uv_loop_init

int uv_loop_init(uv_loop_t* loop) {  void* saved_data;  int err;  saved_data = loop->data;  memset(loop, 0, sizeof(*loop));  loop->data = saved_data;  heap_init((struct heap*) &loop->timer_heap);  QUEUE_INIT(&loop->wq);  QUEUE_INIT(&loop->idle_handles);  QUEUE_INIT(&loop->async_handles);  QUEUE_INIT(&loop->check_handles);  QUEUE_INIT(&loop->prepare_handles);  QUEUE_INIT(&loop->handle_queue);  loop->active_handles = 0;  loop->active_reqs.count = 0;  loop->nfds = 0;  loop->watchers = NULL;  loop->nwatchers = 0;  QUEUE_INIT(&loop->pending_queue);  QUEUE_INIT(&loop->watcher_queue);  loop->closing_handles = NULL;  uv__update_time(loop);  loop->async_io_watcher.fd = -1;  loop->async_wfd = -1;  loop->signal_pipefd[0] = -1;  loop->signal_pipefd[1] = -1;  loop->backend_fd = -1;  loop->emfile_fd = -1;  loop->timer_counter = 0;  loop->stop_flag = 0;  err = uv__platform_loop_init(loop);  if (err)    return err;  uv__signal_global_once_init();  err = uv_signal_init(loop, &loop->child_watcher);  if (err)    goto fail_signal_init;  uv__handle_unref(&loop->child_watcher);  loop->child_watcher.flags |= UV__HANDLE_INTERNAL;  QUEUE_INIT(&loop->process_handles);  err = uv_rwlock_init(&loop->cloexec_lock);  if (err)    goto fail_rwlock_init;  err = uv_mutex_init(&loop->wq_mutex);  if (err)    goto fail_mutex_init;  err = uv_async_init(loop, &loop->wq_async, uv__work_done);  if (err)    goto fail_async_init;  uv__handle_unref(&loop->wq_async);  loop->wq_async.flags |= UV__HANDLE_INTERNAL;  return 0;fail_async_init:  uv_mutex_destroy(&loop->wq_mutex);fail_mutex_init:  uv_rwlock_destroy(&loop->cloexec_lock);fail_rwlock_init:  uv__signal_loop_cleanup(loop);fail_signal_init:  uv__platform_loop_delete(loop);  return err;}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:81,


示例6: uv_update_time

void uv_update_time(uv_loop_t* loop) {  uv__update_time(loop);}
开发者ID:Fantasticer,项目名称:libuv,代码行数:3,


示例7: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct kevent events[1024];  struct kevent* ev;  struct timespec spec;  unsigned int nevents;  unsigned int revents;  QUEUE* q;  uint64_t base;  uint64_t diff;  uv__io_t* w;  int filter;  int fflags;  int count;  int nfds;  int fd;  int op;  int i;  if (loop->nfds == 0) {    assert(QUEUE_EMPTY(&loop->watcher_queue));    return;  }  nevents = 0;  while (!QUEUE_EMPTY(&loop->watcher_queue)) {    q = QUEUE_HEAD(&loop->watcher_queue);    QUEUE_REMOVE(q);    QUEUE_INIT(q);    w = QUEUE_DATA(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    assert(w->fd >= 0);    assert(w->fd < (int) loop->nwatchers);    if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) {      filter = EVFILT_READ;      fflags = 0;      op = EV_ADD;      if (w->cb == uv__fs_event) {        filter = EVFILT_VNODE;        fflags = NOTE_ATTRIB | NOTE_WRITE  | NOTE_RENAME               | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE;        op = EV_ADD | EV_ONESHOT; /* Stop the event from firing repeatedly. */      }      EV_SET(events + nevents, w->fd, filter, op, fflags, 0, 0);      if (++nevents == ARRAY_SIZE(events)) {        if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL))          abort();        nevents = 0;      }    }    if ((w->events & UV__POLLOUT) == 0 && (w->pevents & UV__POLLOUT) != 0) {      EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);      if (++nevents == ARRAY_SIZE(events)) {        if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL))          abort();        nevents = 0;      }    }    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;; nevents = 0) {    if (timeout != -1) {      spec.tv_sec = timeout / 1000;      spec.tv_nsec = (timeout % 1000) * 1000000;    }    nfds = kevent(loop->backend_fd,                  events,                  nevents,                  events,                  ARRAY_SIZE(events),                  timeout == -1 ? NULL : &spec);    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      return;    }    if (nfds == -1) {      if (errno != EINTR)        abort();//.........这里部分代码省略.........
开发者ID:2saki,项目名称:node,代码行数:101,


示例8: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct port_event events[1024];  struct port_event* pe;  struct timespec spec;  QUEUE* q;  uv__io_t* w;  uint64_t base;  uint64_t diff;  unsigned int nfds;  unsigned int i;  int saved_errno;  int nevents;  int count;  int fd;  if (loop->nfds == 0) {    assert(QUEUE_EMPTY(&loop->watcher_queue));    return;  }  while (!QUEUE_EMPTY(&loop->watcher_queue)) {    q = QUEUE_HEAD(&loop->watcher_queue);    QUEUE_REMOVE(q);    QUEUE_INIT(q);    w = QUEUE_DATA(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0))      abort();    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;;) {    if (timeout != -1) {      spec.tv_sec = timeout / 1000;      spec.tv_nsec = (timeout % 1000) * 1000000;    }    /* Work around a kernel bug where nfds is not updated. */    events[0].portev_source = 0;    nfds = 1;    saved_errno = 0;    if (port_getn(loop->backend_fd,                  events,                  ARRAY_SIZE(events),                  &nfds,                  timeout == -1 ? NULL : &spec)) {      /* Work around another kernel bug: port_getn() may return events even       * on error.       */      if (errno == EINTR || errno == ETIME)        saved_errno = errno;      else        abort();    }    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (events[0].portev_source == 0) {      if (timeout == 0)        return;      if (timeout == -1)        continue;      goto update_timeout;    }    if (nfds == 0) {      assert(timeout != -1);      return;    }    nevents = 0;    for (i = 0; i < nfds; i++) {      pe = events + i;      fd = pe->portev_object;      assert(fd >= 0);      assert((unsigned) fd < loop->nwatchers);      w = loop->watchers[fd];      /* File descriptor that we've stopped watching, ignore. */      if (w == NULL)        continue;      w->cb(loop, w, pe->portev_events);//.........这里部分代码省略.........
开发者ID:2saki,项目名称:node,代码行数:101,


示例9: uv__io_poll

//.........这里部分代码省略.........     */    if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout)      timeout = max_safe_timeout;    if (sigmask != 0 && no_epoll_pwait != 0)      if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))        abort();    if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {      nfds = uv__epoll_pwait(loop->backend_fd,                             events,                             ARRAY_SIZE(events),                             timeout,                             sigmask);      if (nfds == -1 && errno == ENOSYS)        no_epoll_pwait = 1;    } else {      nfds = uv__epoll_wait(loop->backend_fd,                            events,                            ARRAY_SIZE(events),                            timeout);      if (nfds == -1 && errno == ENOSYS)        no_epoll_wait = 1;    }    if (sigmask != 0 && no_epoll_pwait != 0)      if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL))        abort();    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      timeout = real_timeout - timeout;      if (timeout > 0)        continue;      return;    }    if (nfds == -1) {      if (errno == ENOSYS) {        /* epoll_wait() or epoll_pwait() failed, try the other system call. */        assert(no_epoll_wait == 0 || no_epoll_pwait == 0);        continue;      }      if (errno != EINTR)        abort();      if (timeout == -1)        continue;      if (timeout == 0)        return;      /* Interrupted by a signal. Update timeout and poll again. */      goto update_timeout;    }    nevents = 0;
开发者ID:Muraad,项目名称:harmony,代码行数:67,


示例10: uv__io_poll

//.........这里部分代码省略.........  if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {    pset = &set;    sigemptyset(pset);    sigaddset(pset, SIGPROF);  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;; nevents = 0) {    if (timeout != -1) {      spec.tv_sec = timeout / 1000;      spec.tv_nsec = (timeout % 1000) * 1000000;    }    if (pset != NULL)      pthread_sigmask(SIG_BLOCK, pset, NULL);    nfds = kevent(loop->backend_fd,                  events,                  nevents,                  events,                  ARRAY_SIZE(events),                  timeout == -1 ? NULL : &spec);    if (pset != NULL)      pthread_sigmask(SIG_UNBLOCK, pset, NULL);    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      return;    }    if (nfds == -1) {      if (errno != EINTR)        abort();      if (timeout == 0)        return;      if (timeout == -1)        continue;      /* Interrupted by a signal. Update timeout and poll again. */      goto update_timeout;    }    have_signals = 0;    nevents = 0;    assert(loop->watchers != NULL);    loop->watchers[loop->nwatchers] = (void*) events;    loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;    for (i = 0; i < nfds; i++) {      ev = events + i;      fd = ev->ident;      /* Skip invalidated events, see uv__platform_invalidate_fd */      if (fd == -1)        continue;
开发者ID:119120119,项目名称:node,代码行数:67,


示例11: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct pollfd events[1024];  struct pollfd pqry;  struct pollfd* pe;  struct poll_ctl pc;  QUEUE* q;  uv__io_t* w;  uint64_t base;  uint64_t diff;  int nevents;  int count;  int nfds;  int i;  int rc;  int add_failed;  if (loop->nfds == 0) {    assert(QUEUE_EMPTY(&loop->watcher_queue));    return;  }  while (!QUEUE_EMPTY(&loop->watcher_queue)) {    q = QUEUE_HEAD(&loop->watcher_queue);    QUEUE_REMOVE(q);    QUEUE_INIT(q);    w = QUEUE_DATA(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    assert(w->fd >= 0);    assert(w->fd < (int) loop->nwatchers);    pc.events = w->pevents;    pc.fd = w->fd;    add_failed = 0;    if (w->events == 0) {      pc.cmd = PS_ADD;      if (pollset_ctl(loop->backend_fd, &pc, 1)) {        if (errno != EINVAL) {          assert(0 && "Failed to add file descriptor (pc.fd) to pollset");          abort();        }        /* Check if the fd is already in the pollset */        pqry.fd = pc.fd;        rc = pollset_query(loop->backend_fd, &pqry);        switch (rc) {        case -1:           assert(0 && "Failed to query pollset for file descriptor");          abort();        case 0:          assert(0 && "Pollset does not contain file descriptor");          abort();        }        /* If we got here then the pollset already contained the file descriptor even though         * we didn't think it should. This probably shouldn't happen, but we can continue. */        add_failed = 1;      }    }    if (w->events != 0 || add_failed) {      /* Modify, potentially removing events -- need to delete then add.       * Could maybe mod if we knew for sure no events are removed, but       * content of w->events is handled above as not reliable (falls back)       * so may require a pollset_query() which would have to be pretty cheap       * compared to a PS_DELETE to be worth optimizing. Alternatively, could       * lazily remove events, squelching them in the mean time. */      pc.cmd = PS_DELETE;      if (pollset_ctl(loop->backend_fd, &pc, 1)) {        assert(0 && "Failed to delete file descriptor (pc.fd) from pollset");        abort();      }      pc.cmd = PS_ADD;      if (pollset_ctl(loop->backend_fd, &pc, 1)) {        assert(0 && "Failed to add file descriptor (pc.fd) to pollset");        abort();      }    }    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;;) {    nfds = pollset_poll(loop->backend_fd,                        events,                        ARRAY_SIZE(events),                        timeout);    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      return;    }//.........这里部分代码省略.........
开发者ID:2014lh,项目名称:node-v0.x-archive,代码行数:101,


示例12: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct uv__epoll_event events[1024];  struct uv__epoll_event* pe;  struct uv__epoll_event e;  QUEUE* q;  uv__io_t* w;  uint64_t base;  uint64_t diff;  int nevents;  int count;  int nfds;  int fd;  int op;  int i;  if (loop->nfds == 0) {    assert(QUEUE_EMPTY(&loop->watcher_queue));    return;  }  while (!QUEUE_EMPTY(&loop->watcher_queue)) {    q = QUEUE_HEAD(&loop->watcher_queue);    QUEUE_REMOVE(q);    QUEUE_INIT(q);    w = QUEUE_DATA(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    assert(w->fd >= 0);    assert(w->fd < (int) loop->nwatchers);    e.events = w->pevents;    e.data = w->fd;    if (w->events == 0)      op = UV__EPOLL_CTL_ADD;    else      op = UV__EPOLL_CTL_MOD;    /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching     * events, skip the syscall and squelch the events after epoll_wait().     */    if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) {      if (errno != EEXIST)        abort();      assert(op == UV__EPOLL_CTL_ADD);      /* We've reactivated a file descriptor that's been watched before. */      if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e))        abort();    }    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;;) {    nfds = uv__epoll_wait(loop->backend_fd,                          events,                          ARRAY_SIZE(events),                          timeout);    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      return;    }    if (nfds == -1) {      if (errno != EINTR)        abort();      if (timeout == -1)        continue;      if (timeout == 0)        return;      /* Interrupted by a signal. Update timeout and poll again. */      goto update_timeout;    }    nevents = 0;    for (i = 0; i < nfds; i++) {      pe = events + i;      fd = pe->data;      assert(fd >= 0);      assert((unsigned) fd < loop->nwatchers);      w = loop->watchers[fd];//.........这里部分代码省略.........
开发者ID:adamsch1,项目名称:libuv,代码行数:101,


示例13: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct pollfd pfd;  struct pollfd* pe;  QUEUE* q;  uv__io_t* w;  uint64_t base;  uint64_t diff;  int nevents;  int count;  int nfd;  int i;  if (loop->nfds == 0) {    assert(QUEUE_EMPTY(&loop->watcher_queue));    return;  }  while (!QUEUE_EMPTY(&loop->watcher_queue)) {    q = QUEUE_HEAD(&loop->watcher_queue);    QUEUE_REMOVE(q);    QUEUE_INIT(q);    w = QUEUE_DATA(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    assert(w->fd >= 0);    assert(w->fd < (int)loop->nwatchers);    pfd.fd = w->fd;    pfd.events = w->pevents;    uv__add_pollfd(loop, &pfd);    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 5;  for (;;) {    nfd = poll(loop->pollfds, loop->npollfds, timeout);    SAVE_ERRNO(uv__update_time(loop));    if (nfd == 0) {      assert(timeout != -1);      return;    }    if (nfd == -1) {      int err = get_errno();      if (err == EAGAIN ) {        set_errno(0);      }      else if ( err != EINTR) {        TDLOG("uv__io_poll abort for errno(%d)", err);        ABORT();      }      if (timeout == -1) {        continue;      }      if (timeout == 0) {        return;      }      goto update_timeout;    }    nevents = 0;    for (i = 0; i < loop->npollfds; ++i) {      pe = &loop->pollfds[i];      if (pe->fd >= 0) {        if (pe->revents & (POLLIN | POLLOUT | POLLHUP)) {          w = loop->watchers[pe->fd];          if (w == NULL) {            uv__rem_pollfd(loop, pe);          } else {            w->cb(loop, w, pe->revents);            ++nevents;          }        }      }    }    if (nevents != 0) {      if (--count != 0) {        timeout = 0;        continue;      }      return;    }    if (timeout == 0) {      return;    }    if (timeout == -1) {      continue;    }update_timeout:    assert(timeout > 0);//.........这里部分代码省略.........
开发者ID:Samsung,项目名称:libtuv,代码行数:101,


示例14: uv__io_poll

void uv__io_poll(uv_loop_t* loop, int timeout) {  struct uv__epoll_event events[1024];  struct uv__epoll_event* pe;  struct uv__epoll_event e;  ngx_queue_t* q;  uv__io_t* w;  uint64_t base;  uint64_t diff;  int nevents;  int count;  int nfds;  int fd;  int op;  int i;  if (loop->nfds == 0) {    assert(ngx_queue_empty(&loop->watcher_queue));    return;  }  while (!ngx_queue_empty(&loop->watcher_queue)) {    q = ngx_queue_head(&loop->watcher_queue);    ngx_queue_remove(q);    ngx_queue_init(q);    w = ngx_queue_data(q, uv__io_t, watcher_queue);    assert(w->pevents != 0);    assert(w->fd >= 0);    assert(w->fd < (int) loop->nwatchers);    e.events = w->pevents;    e.data = w->fd;    if (w->events == 0)      op = UV__EPOLL_CTL_ADD;    else      op = UV__EPOLL_CTL_MOD;    /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching     * events, skip the syscall and squelch the events after epoll_wait().     */    if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) {      if (errno != EEXIST)        abort();      assert(op == UV__EPOLL_CTL_ADD);      /* We've reactivated a file descriptor that's been watched before. */      if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e))        abort();    }    w->events = w->pevents;  }  assert(timeout >= -1);  base = loop->time;  count = 48; /* Benchmarks suggest this gives the best throughput. */  for (;;) {    nfds = uv__epoll_wait(loop->backend_fd,                          events,                          ARRAY_SIZE(events),                          timeout);    /* Update loop->time unconditionally. It's tempting to skip the update when     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the     * operating system didn't reschedule our process while in the syscall.     */    SAVE_ERRNO(uv__update_time(loop));    if (nfds == 0) {      assert(timeout != -1);      return;    }    if (nfds == -1) {      if (errno != EINTR)        abort();      if (timeout == -1)        continue;      if (timeout == 0)        return;      /* Interrupted by a signal. Update timeout and poll again. */      goto update_timeout;    }    nevents = 0;    assert(loop->watchers != NULL);    loop->watchers[loop->nwatchers] = (void*) events;    loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;    for (i = 0; i < nfds; i++) {      pe = events + i;      fd = pe->data;      /* Skip invalidated events, see uv__platform_invalidate_fd *///.........这里部分代码省略.........
开发者ID:Saxophone-Bob,项目名称:first_app,代码行数:101,



注:本文中的uv__update_time函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uv_accept函数代码示例
C++ uv__stream_open函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。