I found Wren a few days ago too and I've been integrating it with Zig and having a blast!
You may have noticed that calling foreign methods from Wren really only works with wrenInterpret, and can't be used for reentrancy from wrenCall, making the whole foreign method system apparently rather useless for fiber event loops.
I switched from foreign method calls to doing yields with operation request values. Zig resumes a fiber by calling it, and gets back its next "foreign call" as the return value when it yields again. This works perfectly well.
It also inspired me to go further and let fibers yield whole batches of requests, almost like io_uring...
You may have noticed that calling foreign methods from Wren really only works with wrenInterpret, and can't be used for reentrancy from wrenCall, making the whole foreign method system apparently rather useless for fiber event loops.
I switched from foreign method calls to doing yields with operation request values. Zig resumes a fiber by calling it, and gets back its next "foreign call" as the return value when it yields again. This works perfectly well.
It also inspired me to go further and let fibers yield whole batches of requests, almost like io_uring...