Closed ezio416 closed 4 months ago
Why not just copy paste this?
void yield_n(int n) {
while ((n = n - 1) >= 0) yield();
}
That's essentially what I've been doing, it's why I say it's just a small convenience thing so I don't need a snippet and it would feel more consistent with sleep
Interesting, for some reason I thought I already had this implemented, but I guess not 🤔 I wonder if there's a reason for that..
I have added yieldframes
: (if you have a better name for this please let me know, I kinda hate this function name)
void yieldframes(uint frames)
Additionally, passing 0 here will produce a no-op.
I am also considering changing the behavior of sleep()
to produce a no-op when 0 is passed. The verdict on whether that's a good idea or not is still out. Feedback welcome. I am also opening a Discord thread to discuss this.
Thanks, yeah I agree the name is not the best - I think keeping it yield
with a default value of 1 would be fine, that way we just have one function for it and it shouldn't break any existing code. It makes sense to me to have yield(0)
and sleep(0)
be no-ops, but I see there's a lot of discussion about that in the discord already
I'm a little nervous about making it the same function name as it could create some confusion, but maybe we could make it an overload instead of a default parameter to reduce potential confusion.
small convenience thing, would just like to be able to yield for multiple frames by passing in a
uint
likeyield(10)
similar to howsleep
worksof course it would need to be defined like
yield(uint frames = 1) {}
to keep compatibility