mirror of
https://github.com/janet-lang/janet
synced 2025-11-06 02:23:03 +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:
@@ -448,11 +448,15 @@ static int thread_worker(JanetMailbox *mailbox) {
|
||||
Janet argv[1] = { parentv };
|
||||
fiber = janet_fiber(func, 64, 1, argv);
|
||||
JanetSignal sig = janet_continue(fiber, janet_wrap_nil(), &out);
|
||||
if (sig != JANET_SIGNAL_OK) {
|
||||
if (sig != JANET_SIGNAL_OK && sig < JANET_SIGNAL_USER0) {
|
||||
janet_eprintf("in thread %v: ", janet_wrap_abstract(janet_make_thread(mailbox, encode)));
|
||||
janet_stacktrace(fiber, out);
|
||||
}
|
||||
|
||||
#ifdef JANET_NET
|
||||
janet_loop();
|
||||
#endif
|
||||
|
||||
/* Normal exit */
|
||||
janet_deinit();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user