blob: 135bd7e52248812317bf41a75c8f72baaff1358f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
pub fn Yield(comptime Type: anytype) type {
return struct {
frame: @Frame(Type) = undefined,
wait: bool = false,
pub fn set(this: *@This(), frame: anytype) void {
this.wait = true;
this.frame = frame.*;
}
pub fn maybeResume(this: *@This()) void {
if (!this.wait) return;
this.wait = false;
resume this.frame;
}
};
}
|