You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Signal::delay simply uses a frame countdown to delay yielding frames from the inner signal. Only once the countdown reaches 0 does it begin requesting frames from the delayed signal.
One potential issue with this is that next is not called on the inner signal until the delay countdown is complete. This can be a problem if the inner signal has some kind of side-effect, e.g. if it monitors the signal in some way and sends values to another thread, a large delay will cause monitoring to hault for the duration of the delay.
This could be fixed by using a fixed-length ring buffer. In this case, a frame could be requested from the inner signal every timenext is called (rather than just after the delay is finished) and instead of yielding them immediately they are pushed to the back of the ring buffer and the frame at the front of the ring buffer is returned instead. This way the output would have the same behaviour as the current delay, but it would ensure that next is called on the inner signal every frame.
An alternative approach might be to offer both? The current implementation is much more memory efficient, especially in the case of long delays, and so would surely be preferable in some cases. I can see a couple of options for this:
Provide two methods. E.g. change delay to use a ring buffer, and move the current implementation to a lazy_delay method?
Make Delay generic over usize (a number of frames) and ring_buffer::Fixed (buffered delay).
The text was updated successfully, but these errors were encountered:
Currently
Signal::delay
simply uses a frame countdown to delay yielding frames from the inner signal. Only once the countdown reaches0
does it begin requesting frames from the delayed signal.One potential issue with this is that
next
is not called on the inner signal until the delay countdown is complete. This can be a problem if the inner signal has some kind of side-effect, e.g. if it monitors the signal in some way and sends values to another thread, a large delay will cause monitoring to hault for the duration of the delay.This could be fixed by using a fixed-length ring buffer. In this case, a frame could be requested from the inner signal every time
next
is called (rather than just after the delay is finished) and instead of yielding them immediately they are pushed to the back of the ring buffer and the frame at the front of the ring buffer is returned instead. This way the output would have the same behaviour as the current delay, but it would ensure thatnext
is called on the inner signal every frame.An alternative approach might be to offer both? The current implementation is much more memory efficient, especially in the case of long delays, and so would surely be preferable in some cases. I can see a couple of options for this:
delay
to use a ring buffer, and move the current implementation to alazy_delay
method?Delay
generic overusize
(a number of frames) andring_buffer::Fixed
(buffered delay).The text was updated successfully, but these errors were encountered: