Closed trentgill closed 3 years ago
clock is the preferred way of doing delay in norns, so i'm all for this change
On Thu, Jun 24, 2021 at 11:49 AM trent @.***> wrote:
at present, delay is implemented in terms of metro. it allocates a metro, then de-allocates itself once the event occurs.
this causes issues if a script uses the metro[n] method of directly accessing metros. this is because an indexed metro call isn't "allocated", and so delay doesn't know not to use that particular instance.
rather than trying to fix this in the metro lib (which i'm skeptical is possible), i propose re-implementing delay in terms of clock:
-- untested!function delay(action, time, repeats) local r = repeats or 0 return clock.run(function() for i=1,1+r do clock.sleep(time) action(i) end end)end
an added benefit is it enables up to 100 simultaneous delays, as opposed to being limited by metro's 8 instances.
this would technically be a breaking change because the delay function currently returns a metro reference, while now it returns a clock coro_id. i think this usage was very rare (most uses just discard the return value), but just calling it out as a potential issue.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/monome/crow/issues/413, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4I4CM7TDWEJHRP6YIEKTTUNHZHANCNFSM47IFGPTA .
fixed in #416
at present,
delay
is implemented in terms ofmetro
. it allocates a metro, then de-allocates itself once the event occurs.this causes issues if a script uses the
metro[n]
method of directly accessing metros. this is because an indexed metro call isn't "allocated", and sodelay
doesn't know not to use that particular instance.rather than trying to fix this in the metro lib (which i'm skeptical is possible), i propose re-implementing
delay
in terms ofclock
:an added benefit is it enables up to 100 simultaneous delays, as opposed to being limited by metro's 8 instances.
this would technically be a breaking change because the
delay
function currently returns ametro
reference, while now it returns aclock
coro_id. i think this usage was very rare (most uses just discard the return value), but just calling it out as a potential issue.