mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-16 05:59:06 +00:00
8280832: Update usage docs for NonblockingQueue
Reviewed-by: iwalulya, dholmes
This commit is contained in:
parent
d442328bc2
commit
3ce1c5b6ce
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -96,9 +96,11 @@ public:
|
||||
inline size_t length() const;
|
||||
|
||||
// Thread-safe add the object to the end of the queue.
|
||||
// Subject to ABA behavior; callers must ensure usage is safe.
|
||||
inline void push(T& node) { append(node, node); }
|
||||
|
||||
// Thread-safe add the objects from first to last to the end of the queue.
|
||||
// Subject to ABA behavior; callers must ensure usage is safe.
|
||||
inline void append(T& first, T& last);
|
||||
|
||||
// Thread-safe attempt to remove and return the first object in the queue.
|
||||
|
||||
@ -117,6 +117,12 @@ void NonblockingQueue<T, next_ptr>::append(T& first, T& last) {
|
||||
// other push/append could have competed with us, because we claimed
|
||||
// old_tail for extension. We won any races with try_pop by changing
|
||||
// away from end-marker. So we're done.
|
||||
//
|
||||
// Note that ABA is possible here. A concurrent try_pop could take
|
||||
// old_tail before our update of old_tail's next_ptr, old_tail gets
|
||||
// recycled and re-added to the end of this queue, and then we
|
||||
// successfully cmpxchg, making the list in _tail circular. Callers
|
||||
// must ensure this can't happen.
|
||||
return;
|
||||
} else {
|
||||
// A concurrent try_pop has claimed old_tail, so it is no longer in the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user