-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Do we need to pass Fiber.current to C 50 different times? #102
Comments
The second option is not an option because it involves implementation details. The first option is impossible because it requires reentrancy. |
Ah, duh. Right.
I assume that you're speaking WRT to Is there anything truly unsafe about doing this that I'm missing - or is the problem just that "it could break" because you're technically using a private API? Where-as (eventually) we'd make guarantees about the public API. |
"Unsafe" as in "memory safety"? No. But I wouldn't do that. Another thing we can do, however, is to expose a |
I would agree. That was going to be my next question/suggestion. :) Until then we could just do (branch updated): static await_(fn) {
preserveFiberCurrent_(Fiber.current)
fn.call()
return Scheduler.runNextScheduled_()
} So no re-entrance issues, await just pushes the current fiber down into C directly so that it's always available on the C side... if you're using |
I'm looking into cleaning up the Scheduler stuff further and it seems that the C code already knows the current fiber... we shouldn't need every single function preparing to suspend itself to pass
Fiber.current
down into C. We could either retrieve it by doing the traditional dance:Or the much simpler:
Is there a good reason to prefer one over the other? Would simply calling
vm->fiber()
directly be frowned upon (private API or some such concerns?) I can't imagine this is something that would be changing super often in the implementation.The below commit makes this change for just Timer:
joshgoebel@6639dcf
The text was updated successfully, but these errors were encountered: