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

Function uv__work_cancel

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

TODO(bnoordhuis) teach libuv how to cancel file operations * that go through io_uring instead of the thread pool. */

Source from the content-addressed store, hash-verified

279 * that go through io_uring instead of the thread pool.
280 */
281static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) {
282 int cancelled;
283
284 uv_once(&once, init_once); /* Ensure |mutex| is initialized. */
285 uv_mutex_lock(&mutex);
286 uv_mutex_lock(&w->loop->wq_mutex);
287
288 cancelled = !uv__queue_empty(&w->wq) && w->work != NULL;
289 if (cancelled)
290 uv__queue_remove(&w->wq);
291
292 uv_mutex_unlock(&w->loop->wq_mutex);
293 uv_mutex_unlock(&mutex);
294
295 if (!cancelled)
296 return UV_EBUSY;
297
298 w->work = uv__cancelled;
299 uv_mutex_lock(&loop->wq_mutex);
300 uv__queue_insert_tail(&loop->wq, &w->wq);
301 uv_async_send(&loop->wq_async);
302 uv_mutex_unlock(&loop->wq_mutex);
303
304 return 0;
305}
306
307
308void uv__work_done(uv_async_t* handle) {

Callers 1

uv_cancelFunction · 0.85

Calls 7

uv__queue_emptyFunction · 0.85
uv__queue_removeFunction · 0.85
uv__queue_insert_tailFunction · 0.85
uv_onceFunction · 0.50
uv_mutex_lockFunction · 0.50
uv_mutex_unlockFunction · 0.50
uv_async_sendFunction · 0.50

Tested by

no test coverage detected