RFR: 8355726: LinkedBlockingDeque fixes and improvements

kabutz duke at openjdk.org
Mon Jun 9 12:01:06 UTC 2025


On Mon, 9 Jun 2025 09:20:31 GMT, Viktor Klang <vklang at openjdk.org> wrote:

>>> I'm a bit uneasy about incrementing the `count` in `linkFirst` but not enforcing the invariant. What's the benefit to changing linkFirst and linkLast to return void instead of keeping the original returning a boolean?
>> 
>> I based the approach on the LBQ enqueue() and dequeue() methods, which also return void and have a comment with the assertion.
>
> @kabutz I'd think maintaining the invariants within linkFirst and linkLast would be preferable (`count` must be re-read under the lock anyway)

What would you like to do if the invariant fails inside linkFirst() and linkLast()? Should we throw an AssertionError each time?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24925#discussion_r2135589310


More information about the core-libs-dev mailing list