-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
support break in suspend blocks #803
Comments
This feature can be used in a couple of interesting ways with a thread pool: Switch the current function to running in another thread, and run another function in the current thread: suspend |p| {
threadPoolResume(p);
anotherFunction();
break;
} Fork the current function, running it in 2 kernel threads simultaneously: suspend |p| {
threadPoolResume(p);
break;
} |
Also related is what to do when returning from a suspend block: suspend |p| {
var ev = std.os.linux.epoll_event {
.events = EPOLLIN|EPOLLET,
.data = std.os.linux.epoll_data {
.ptr = @ptrToInt(p),
},
};
try epoll_ctl(self.epollfd, EPOLL_CTL_ADD, fd, &ev);
} |
* you can label suspend blocks * labeled break supports suspend blocks See #803
|
Instead of breaking from a suspend block, you have to |
Internally,
await
is asuspend
block that reaches into the coroutine's frame, atomically modifies the awaiter pointer, and then based on the previous value of the awaiter pointer, might decide not to suspend after all.We could expose this ability to zig programmers, like this:
The text was updated successfully, but these errors were encountered: