1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 01:37:19 +00:00

Set fiber env for heavyweight threads.

Since you already incur the cost of creating the
core environment, this is probably what you want anyways.
This will make eval and other reflective code work as expected.
This commit is contained in:
Calvin Rose 2020-07-03 15:20:19 -05:00
parent 7b31a87b3c
commit dc259b9f8e

View File

@ -499,6 +499,10 @@ static int thread_worker(JanetMailboxPair *pair) {
/* Call function */ /* Call function */
Janet argv[1] = { parentv }; Janet argv[1] = { parentv };
fiber = janet_fiber(func, 64, 1, argv); fiber = janet_fiber(func, 64, 1, argv);
if (pair->flags & JANET_THREAD_HEAVYWEIGHT) {
fiber->env = janet_table(0);
fiber->env->proto = janet_core_env(NULL);
}
JanetSignal sig = janet_continue(fiber, janet_wrap_nil(), &out); JanetSignal sig = janet_continue(fiber, janet_wrap_nil(), &out);
if (sig != JANET_SIGNAL_OK && sig < JANET_SIGNAL_USER0) { if (sig != JANET_SIGNAL_OK && sig < JANET_SIGNAL_USER0) {
janet_eprintf("in thread %v: ", janet_wrap_abstract(janet_make_thread(pair->newbox, encode))); janet_eprintf("in thread %v: ", janet_wrap_abstract(janet_make_thread(pair->newbox, encode)));