Re: Why SynchronousQueue.TransferQueue#clean() not clean the last node
Martin Buchholz via Concurrency-interest <[email protected]> Sat, 15 Aug 2020 00:02:20 -0700
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <CA+kOe0_GJ+T1XGpSY0o62K3c-K4UEt5psL2_cR90_90yVDmsfg@mail.gmail.com> |
I did more work on ConcurrentLinkedQueue, including recording the
invariants, notably:
* Invariants:
* - all live nodes are reachable from head via succ()
* - head != null
* - (tmp = head).next != tmp || tmp != head
* Non-invariants:
* - head.item may or may not be null.
* - it is permitted for tail to lag behind head, that is, for tail
* to not be reachable from head!
On Fri, Aug 14, 2020 at 11:23 PM Alex Otenko via Concurrency-interest
<[email protected]> wrote:
>
> Yes. There is an unspoken invariant that head and tail make progress in one direction. That is pretty much the only way to make sure the head never passes the tail. Then deleting tail cannot be done without moving the tail backwards to pred. This breaks the unspoken invariant in the presence of concurrent modifications of head.
>
> Alex
>
> On Sat, 15 Aug 2020, 07:18 Liu, <[email protected]> wrote:
>>
>> Thanks. I just think about it, it is kind of difficult to keep the correctness of tail.
>
> _______________________________________________
> Concurrency-interest mailing list
> [email protected]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest