1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-08 19:43:41 +00:00

Working TCP echo server and client.

Required a few changes to APIs, namely janet_root_fiber()
to get topmost fiber that is active in the current scheduler.
This is distinct from janet_current_fiber(), which gets the bottom
most fiber in the fiber stack - it might have a parent, and so cannot
be reliably resumed.
This is the kind of situation that makes symmetric coroutines more
attractive.
This commit is contained in:
Calvin Rose
2020-02-09 19:04:34 -06:00
parent 7f1f684b21
commit f4d7fd97f6
11 changed files with 341 additions and 92 deletions

View File

@@ -869,10 +869,14 @@ int main(int argc, char **argv) {
JanetFiber *fiber = janet_fiber(janet_unwrap_function(mainfun), 64, 1, mainargs);
fiber->env = env;
status = janet_continue(fiber, janet_wrap_nil(), &out);
if (status != JANET_SIGNAL_OK) {
if (status != JANET_SIGNAL_OK && status < JANET_SIGNAL_USER0) {
janet_stacktrace(fiber, out);
}
#ifdef JANET_NET
janet_loop();
#endif
/* Deinitialize vm */
janet_deinit();
janet_line_deinit();