Re: Why SynchronousQueue.TransferQueue#clean() not clean the last node

Alex Otenko via Concurrency-interest <[email protected]> Sat, 15 Aug 2020 09:24:36 +0100
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CANkgWKjxNZSqSOJhcz9odcY9DuDDuU1tOL4jkgPr_PPgxk+29g@mail.gmail.com>
Great. But still head and tail point to nodes in the same chain, right?

Alex

On Sat, 15 Aug 2020, 08:02 Martin Buchholz, <[email protected]> wrote:

> 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