serebit
04/08/2019, 7:57 PMBroadcastChannel<Unit>
on the top level. Every channel will call subscribe and receive on this channel at the start of processing a request. The variable will usually be null, but if a “global” header is received, it will be set to BroadcastChannel(1)
, and the channel where this header was received will delay for the given amount of time before setting the variable to null and calling send(Unit)
, unsuspending all the waiting channels.
Solution 2️⃣ Hold the global delay target as a unix millis, or null, at the top level. Every channel will delay for the amount it time it takes to get to that unix millis if it is not null. If a channel receives the global header, it sets the global unix millis and delays for that period of time before setting it back to null.octylFractal
04/08/2019, 9:07 PMBroadcastChannel<Long>
that holds a delay if one is needed, and is empty otherwise. your channels can use poll
to determine if they need to wait -- either the Long is there, and they wait until it (like 2), or it is null
and they do not waitserebit
04/08/2019, 9:17 PMBroadcastChannel
doesn’t have a poll
methodoctylFractal
04/08/2019, 9:20 PMoctylFractal
04/08/2019, 9:21 PMserebit
04/08/2019, 9:22 PMoctylFractal
04/08/2019, 9:25 PMserebit
04/08/2019, 9:29 PMserebit
04/08/2019, 9:33 PMoctylFractal
04/08/2019, 9:36 PMoctylFractal
04/08/2019, 9:36 PMoctylFractal
04/08/2019, 9:37 PMAtomicLong
or other thread-safe measuresserebit
04/08/2019, 9:37 PMLong.MAX_VALUE
route channels and then some