MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / uv__work_done

Function uv__work_done

third-party/libuv-1.46.0/src/threadpool.c:308–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307
308void uv__work_done(uv_async_t* handle) {
309 struct uv__work* w;
310 uv_loop_t* loop;
311 struct uv__queue* q;
312 struct uv__queue wq;
313 int err;
314 int nevents;
315
316 loop = container_of(handle, uv_loop_t, wq_async);
317 uv_mutex_lock(&loop->wq_mutex);
318 uv__queue_move(&loop->wq, &wq);
319 uv_mutex_unlock(&loop->wq_mutex);
320
321 nevents = 0;
322
323 while (!uv__queue_empty(&wq)) {
324 q = uv__queue_head(&wq);
325 uv__queue_remove(q);
326
327 w = container_of(q, struct uv__work, wq);
328 err = (w->work == uv__cancelled) ? UV_ECANCELED : 0;
329 w->done(w, err);
330 nevents++;
331 }
332
333 /* This check accomplishes 2 things:
334 * 1. Even if the queue was empty, the call to uv__work_done() should count
335 * as an event. Which will have been added by the event loop when
336 * calling this callback.
337 * 2. Prevents accidental wrap around in case nevents == 0 events == 0.
338 */
339 if (nevents > 1) {
340 /* Subtract 1 to counter the call to uv__work_done(). */
341 uv__metrics_inc_events(loop, nevents - 1);
342 if (uv__get_internal_fields(loop)->current_timeout == 0)
343 uv__metrics_inc_events_waiting(loop, nevents - 1);
344 }
345}
346
347
348static void uv__queue_work(struct uv__work* w) {

Callers

nothing calls this directly

Calls 6

uv__queue_moveFunction · 0.85
uv__queue_emptyFunction · 0.85
uv__queue_headFunction · 0.85
uv__queue_removeFunction · 0.85
uv_mutex_lockFunction · 0.50
uv_mutex_unlockFunction · 0.50

Tested by

no test coverage detected