lean4-htt/src/runtime/libuv.cpp
Henrik Böving e6a643770f
feat: implement basic async IO with timers (#6505)
This PR implements a basic async framework as well as asynchronously
running timers using libuv.

---------

Co-authored-by: Sofia Rodrigues <sofia@algebraic.dev>
Co-authored-by: Markus Himmel <markus@himmel-villmar.de>
Co-authored-by: Markus Himmel <markus@lean-fro.org>
2025-01-13 18:11:04 +00:00

37 lines
No EOL
780 B
C++

/*
Copyright (c) 2024 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Markus Himmel, Sofia Rodrigues
*/
#include <pthread.h>
#include "runtime/libuv.h"
#include "runtime/object.h"
namespace lean {
#ifndef LEAN_EMSCRIPTEN
#include <uv.h>
extern "C" void initialize_libuv() {
initialize_libuv_timer();
initialize_libuv_loop();
lthread([]() { event_loop_run_loop(&global_ev); });
}
/* Lean.libUVVersionFn : Unit → Nat */
extern "C" LEAN_EXPORT lean_obj_res lean_libuv_version(lean_obj_arg o) {
return lean_unsigned_to_nat(uv_version());
}
#else
extern "C" void initialize_libuv() {}
extern "C" LEAN_EXPORT lean_obj_res lean_libuv_version(lean_obj_arg o) {
return lean_box(0);
}
#endif
}