static void uv_poll_ex(uv_loop_t* loop, int block) { BOOL success; DWORD timeout; uv_req_t* req; OVERLAPPED_ENTRY overlappeds[64]; ULONG count; ULONG i; if (block) { timeout = uv_get_poll_timeout(loop); } else { timeout = 0; } assert(pGetQueuedCompletionStatusEx); success = pGetQueuedCompletionStatusEx(loop->iocp, overlappeds, COUNTOF(overlappeds), &count, timeout, FALSE); if (success) { for (i = 0; i < count; i++) { /* Package was dequeued */ req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); uv_insert_pending_req(loop, req); } } else if (GetLastError() != WAIT_TIMEOUT) { /* Serious error */ uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); } }
static void uv_poll(uv_loop_t* loop, int block) { BOOL success; DWORD bytes, timeout; ULONG_PTR key; OVERLAPPED* overlapped; uv_req_t* req; if (block) { timeout = uv_get_poll_timeout(loop); } else { timeout = 0; } success = GetQueuedCompletionStatus(loop->iocp, &bytes, &key, &overlapped, timeout); if (overlapped) { /* Package was dequeued */ req = uv_overlapped_to_req(overlapped); uv_insert_pending_req(loop, req); } else if (GetLastError() != WAIT_TIMEOUT) { /* Serious error */ uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); } }
int uv_run_prework(uv_run_state* state) { BOOL block; uv_update_time(state->loop); uv_process_timers(state->loop); // Call idle callbacks if nothing to do. if (state->loop->pending_reqs_tail == NULL && state->loop->endgame_handles == NULL) { uv_idle_invoke(state->loop); } uv_process_reqs(state->loop); uv_process_endgames(state->loop); if (!UV_LOOP_ALIVE(state->loop)) return FALSE; uv_prepare_invoke(state->loop); block = (state->loop->idle_handles == NULL && state->loop->pending_reqs_tail == NULL && state->loop->endgame_handles == NULL && UV_LOOP_ALIVE(state->loop)); if (block) state->timeout = uv_get_poll_timeout(state->loop); else state->timeout = 0; state->count = 0; return TRUE; }
static void uv_poll_ex(int block) { BOOL success; DWORD timeout; uv_req_t* req; OVERLAPPED_ENTRY overlappeds[64]; ULONG count; ULONG i; if (block) { timeout = uv_get_poll_timeout(); } else { timeout = 0; } assert(pGetQueuedCompletionStatusEx); success = pGetQueuedCompletionStatusEx(LOOP->iocp, overlappeds, COUNTOF(overlappeds), &count, timeout, FALSE); if (success) { for (i = 0; i < count; i++) { /* Package was dequeued */ req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); if (overlappeds[i].lpOverlapped->Internal != STATUS_SUCCESS) { req->error = uv_new_sys_error(pRtlNtStatusToDosError( overlappeds[i].lpOverlapped->Internal)); } uv_insert_pending_req(req); } } else if (GetLastError() != WAIT_TIMEOUT) { /* Serious error */ uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); } }