I want to implement a round-robin-based scheduling for a producer/consumer situation, where the consumers may change during runtime.
In the beginning I used a Queue
which contained all the consumers, dequeued one and immediately enqueued it again to have a circular collection, worked perfectly. Whenever a new consumer registered I just enqueued it to the queue -> done.
However, the problem of removing consumers at runtime (when they send an unsubscribe message) is challenging. Queue does not offer a Remove() method, however, I need to remove them completely from the queue - independently of the consumer's current position within the queue. Obviously the Queue
"interface" is not exactly what I need.
Is there some kind of "circular collection" in C# I haven't heard of?