There is a name for that, but I don’t know what it is, so it’s difficult for Google.
What I'm looking for is something in the java concurrency utilities, which are a couple of queues, a “waiting” queue used by the manufacturer, and a “processing” queue used by the consumer, where the consumer can automatically change the queues. If used in this way (1 producer stream, 1 consumer stream), the individual queues should not be thread safe, but simply links to them.
I know that I saw it somewhere earlier, and I may possibly bend something like this on my own, but if it exists, I would prefer to use it.
edit: I assume that the primitive I'm looking for is a pair of atomic links that can be atomically replaced. (& I can add the queues myself.)
edit 2: @ Alex Miller answered a glaring question about what I was thinking but couldn't remember. However, this does not solve my problem, since it is a flow barrier, and I want the producer not to block.
@Sfossin's value about queuing links is good; I wanted that at the moment when the consumer begins to extract and process the elements from the queue, all these elements of the queue should be complete, and the manufacturer cannot add any elements after that; Now the manufacturer must add items to another queue. Thus, a paired / replaced set of atomic links will not work.
(It seems that if there are 2 school buses, one of which is always waiting for passengers, and the other always delivers them to another place. As soon as the driver gets out, you need to get on another bus. Having links, manufacturers can access the bus, even if it already gone, which is not allowed.)
I think that instead I should use a single ConcurrentLinkedQueue and have a sentinel value that the consumer adds to the queue. This allows multiple manufacturers to use, not just 1. In order for the consumer to process batches of items in the queue, the consumer waits for the queue to queue there was at least 1 element, then inserts a guard board at the end of the queue and removes the elements until the watch is removed. Then the consumer does everything that he has to do between parties. This is the behavior that I wanted.
It does not have to be a guaranteed non-blocking approach (locking or synchronized methods are parameters), but if there is an easy way to archive it so that it is so preferable in my application.