aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/include/janet.h
diff options
context:
space:
mode:
authorbakpakin <calsrose@gmail.com>2021-07-24 15:14:37 -0500
committerbakpakin <calsrose@gmail.com>2021-07-24 15:14:37 -0500
commit160dd830a0a3b3fa2adae7fa22e13088d0e9b540 (patch)
treed080f49285846848239868eccb48671e414011c3 /src/include/janet.h
parentFix typo. (diff)
Add janet_interpreter_interrupt for custom scheduling.
This would allow an embedder to suspend the current Janet fiber via an external event like a signal, other thread, or really anything. This is a useful primitive for custom schedulers that would call janet_interpreter_interupt periodically (say, in an interval with SIG_ALRM), do some work, and then use janet_continue on the janet_root_fiber, or for embedding into other soft-realtime applications like a game. To say, only allow about 5ms per frame of interpreter time.
Diffstat (limited to 'src/include/janet.h')
-rw-r--r--src/include/janet.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/janet.h b/src/include/janet.h
index 7e68236e..61f0e7ad 100644
--- a/src/include/janet.h
+++ b/src/include/janet.h
@@ -1660,9 +1660,11 @@ JANET_API int32_t janet_sorted_keys(const JanetKV *dict, int32_t cap, int32_t *i
JANET_API int janet_init(void);
JANET_API void janet_deinit(void);
JANET_API JanetVM *janet_vm_alloc(void);
+JANET_API JanetVM *janet_local_vm(void);
JANET_API void janet_vm_free(JanetVM *vm);
JANET_API void janet_vm_save(JanetVM *into);
JANET_API void janet_vm_load(JanetVM *from);
+JANET_API void janet_interpreter_interrupt(JanetVM *vm);
JANET_API JanetSignal janet_continue(JanetFiber *fiber, Janet in, Janet *out);
JANET_API JanetSignal janet_continue_signal(JanetFiber *fiber, Janet in, Janet *out, JanetSignal sig);
JANET_API JanetSignal janet_pcall(JanetFunction *fun, int32_t argn, const Janet *argv, Janet *out, JanetFiber **f);