Reputation: 22890
This is the description of the documentation of ConcurrentLinkedQueue:
An unbounded thread-safe queue based on linked nodes. This queue orders elements FIFO (first-in-first-out).
...
This implementation employs an efficient "wait-free" algorithm
Is it possible to be unbounded and wait-free?
I am pretty sure wait-freedom ensures a bound on any operation.
Upvotes: 2
Views: 958
Reputation: 40256
Wait-freedom really just implies within some finite number of steps an operation will complete as explained
An algorithm is wait-free if every operation has a bound on the number of steps the algorithm will take before the operation completes
This definition doesn't apply to the ConcurrentLinkedQueue
. When polling (or putting) a queue, each thread has the likelihood of failing an infinite number of times. This fact alone tells us that the queue is not truly wait free. I believe the author isn't using the definition of wait-free from Herlihy in The Art of Multiprocessor Programming.
For more information, the CLQ uses a Michael & Scott alogrithm that is explained here
Edit: Just realised the link I gave for the M and S queue is also in the API. Either should be fine.
Upvotes: 2
Reputation: 70564
I am pretty sure wait-freedom ensures a bound on any operation.
A bound on the time (or number of instructions, or whatever) taken by the operation.
In that JavaDoc, "Unbounded" probably refers to the number of elements the queue may contain.
For instance, the JavaDoc for LinkedBlockingDeque writes:
An optionally-bounded blocking deque based on linked nodes.
The optional capacity bound constructor argument serves as a way to prevent excessive expansion. The capacity, if unspecified, is equal to Integer.MAX_VALUE. Linked nodes are dynamically created upon each insertion unless this would bring the deque above capacity.
Upvotes: 8