[concurrency-interest] Bulk queue operations

David Holmes dholmes@dltech.com.au
Fri, 17 Dec 2004 15:25:00 +1000


> Could you tell me why Queue or BlockingQueue don't provide atomic bulk
> operations like offerMany, putMany and takeMany?

If the intent of these bulk operations is to offer/put/take the next n
elements - ensuring no other producers/consumers get to touch the queue in
between - then only certain types of implementation can easily support such
semantics ie lock-based implementations. Such operations would have to be
defined in a seperate interface to avoid burdening all Queue and
BlockingQueue implementations. Such an interface wasn't defined because
there was no real requirement for it at the time.

If the intent is not to enforce ordering, then looping on the existing
offer/put/take methods achieves the same thing.

David Holmes