diff third_party/libuv/docs/code/idle-basic/main.c @ 173:827c6ac504cd hg-web

Merged in default here.
author MrJuneJune <me@mrjunejune.com>
date Mon, 19 Jan 2026 18:59:10 -0800
parents 948de3f54cea
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/third_party/libuv/docs/code/idle-basic/main.c	Mon Jan 19 18:59:10 2026 -0800
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <uv.h>
+
+int64_t counter = 0;
+
+void wait_for_a_while(uv_idle_t* handle) {
+    counter++;
+
+    if (counter >= 10e6)
+        uv_idle_stop(handle);
+}
+
+int main() {
+    uv_idle_t idler;
+
+    uv_idle_init(uv_default_loop(), &idler);
+    uv_idle_start(&idler, wait_for_a_while);
+
+    printf("Idling...\n");
+    uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+    uv_loop_close(uv_default_loop());
+    return 0;
+}