@@ -35,6 +35,7 @@ pub const PauseReason = union(enum) {
3535 /// Task volutarily gave up execution, but is ready to continue.
3636 yield ,
3737 sleep_until : time .Absolute align (@alignOf (StackUint )),
38+ bits_mask_any_high : struct { ptr : * const usize , mask : usize },
3839 /// This value means there is no context stored on this stack
3940 /// so it can be used to launch a new task.
4041 no_task ,
@@ -46,11 +47,13 @@ pub const PauseReason = union(enum) {
4647 /// Check if the task should be resumed.
4748 /// The io interface may not be necessary.
4849 pub fn can_resume (this : * const @This (), io : anytype ) bool {
49- _ = io ;
5050 return switch (this .* ) {
5151 .no_task = > false ,
5252 .yield = > true ,
53- .sleep_until = > | t | t .is_reached_by (rp2xxx .time .get_time_since_boot ()),
53+ .bits_mask_any_high = > | info | {
54+ return @atomicLoad (usize , info .ptr , .acquire ) & info .mask != 0 ;
55+ },
56+ .sleep_until = > | t | t .is_reached_by (io .monotonic_clock ()),
5457 };
5558 }
5659
@@ -300,4 +303,9 @@ pub const RoundRobin = struct {
300303 // Maybe we could wait for them to complete instead?
301304 std .debug .panic ("Cannot launch more tasks." , .{});
302305 }
306+
307+ pub fn monotonic_clock (this : * @This ()) time.Absolute {
308+ _ = this ;
309+ return rp2xxx .time .get_time_since_boot ();
310+ }
303311};
0 commit comments