Rx — Custom traffic shaper

Regular Rx Buffer(200) emits data every 200 milliseconds. Let’s implement an operator which will emit data each 200 milliseconds or immediately if nothing was emitted in last interval. It’s like a traffic shaper which will give you data as soon as possible bot not more often than each 200 millis.

Sample implementation:

Output:

This is not optimal, there are probably too many continuations scheduled, also we lock directly instead of using some interlocked. However, seems like it’s working.