Maintain a sorted list of entries. More...
#include <AtomicList.h>

Public Member Functions | |
| AtomicList (const AtomicList &)=delete | |
| AtomicList (size_t capacity=1024, const TYPE &default_value=TYPE(), const COMPARE &comp=COMPARE()) | |
| Default constructor. | |
| constexpr size_t | available () const |
| Return the available space. | |
| constexpr size_t | capacity () const |
| Return the capacity of the list. | |
| bool | check () |
| Check the list. | |
| void | clear () |
| Clear the list. | |
| bool | empty () const |
| Check if the list is empty. | |
| void | insert (const TYPE &x) |
| Insert an item. | |
| size_t | N_insert () const |
| Return the total number of inserts since object creation. | |
| size_t | N_remove () const |
| Return the total number of removals since object creation. | |
| AtomicList & | operator= (const AtomicList &)=delete |
| template<typename Compare , class... Args> | |
| TYPE | remove (Compare compare, const Args &...args) |
| Remove an item from the list. | |
| TYPE | remove_first () |
| Remove the first from the list. | |
| size_t | size () const |
| Return the size of the list. | |
| ~AtomicList () | |
| Destructor. | |
Private Member Functions | |
| int | get_unused () |
| int | lock (int i) |
| void | put_unused (int i) |
| void | unlock (int i, int value) |
Private Attributes | |
| const size_t | d_capacity |
| COMPARE | d_compare |
| volatile TYPE | d_default |
| volatile std::atomic_int32_t | d_N |
| volatile std::atomic_int64_t | d_N_insert |
| volatile std::atomic_int64_t | d_N_remove |
| volatile std::atomic_int32_t * | d_next |
| volatile TYPE * | d_objects |
| volatile std::atomic_int32_t | d_unused |
Maintain a sorted list of entries.
This class implements a basic sorted list that is thread-safe and lock-free. Entries are stored smallest to largest according to the compare operator
Definition at line 19 of file AtomicList.h.
| AMP::AtomicList< TYPE, COMPARE >::AtomicList | ( | size_t | capacity = 1024, |
| const TYPE & | default_value = TYPE(), |
||
| const COMPARE & | comp = COMPARE() |
||
| ) |
Default constructor.
| AMP::AtomicList< TYPE, COMPARE >::~AtomicList | ( | ) |
Destructor.
|
delete |
|
inlineconstexpr |
Return the available space.
Return the current available space (capacity - size)
Definition at line 87 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_capacity, and AMP::AtomicList< TYPE, COMPARE >::size().
|
inlineconstexpr |
Return the capacity of the list.
Return the maximum number of items the list can hold
Definition at line 81 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_capacity.
Referenced by AMP::ThreadPoolListQueue::capacity().
|
inline |
Check the list.
Perform a series of checks to verify the list is in a stable state. Note: This function is only partially thread-safe: it will block all other operations on the list, but check may fail if we caught a thread modifying the list. It is intended for debugging purposes only!
|
inline |
Clear the list.
Removes all entries from the list
Definition at line 71 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::empty(), and AMP::AtomicList< TYPE, COMPARE >::remove_first().
|
inline |
Check if the list is empty.
Return true if the list is empty
Definition at line 65 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_N.
Referenced by AMP::AtomicList< TYPE, COMPARE >::clear(), and AMP::ThreadPoolListQueue::empty().
|
inlineprivate |
Definition at line 136 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_next, and AMP::AtomicList< TYPE, COMPARE >::d_unused.
|
inline |
Insert an item.
Insert an item into the list
| x | Item to insert |
Referenced by AMP::ThreadPoolListQueue::changePriorities(), and AMP::ThreadPoolListQueue::insert().
|
inlineprivate |
Definition at line 121 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_next.
|
inline |
Return the total number of inserts since object creation.
Definition at line 102 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_N_insert.
|
inline |
Return the total number of removals since object creation.
Definition at line 106 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_N_remove.
|
delete |
|
inlineprivate |
Definition at line 146 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_next, and AMP::AtomicList< TYPE, COMPARE >::d_unused.
|
inline |
Remove an item from the list.
Find and remove first entry that meets the given criteria
| compare | Comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the given value meets the selection criteria. The signature of the comparison function should be equivalent to: bool cmp( const TYPE& value, ... ); |
| args | Additional arguments for the comparison |
Referenced by AMP::ThreadPoolListQueue::changePriorities(), and AMP::ThreadPoolListQueue::pop().
|
inline |
Remove the first from the list.
Referenced by AMP::AtomicList< TYPE, COMPARE >::clear().
|
inline |
Return the size of the list.
Return the number of items in the list
Definition at line 59 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_N.
Referenced by AMP::AtomicList< TYPE, COMPARE >::available(), and AMP::ThreadPoolListQueue::size().
|
inlineprivate |
Definition at line 131 of file AtomicList.h.
References AMP::AtomicList< TYPE, COMPARE >::d_next.
|
private |
Definition at line 111 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::available(), and AMP::AtomicList< TYPE, COMPARE >::capacity().
|
private |
Definition at line 110 of file AtomicList.h.
|
private |
Definition at line 112 of file AtomicList.h.
|
private |
Definition at line 114 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::empty(), and AMP::AtomicList< TYPE, COMPARE >::size().
|
private |
Definition at line 117 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::N_insert().
|
private |
Definition at line 118 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::N_remove().
|
private |
Definition at line 115 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::get_unused(), AMP::AtomicList< TYPE, COMPARE >::lock(), AMP::AtomicList< TYPE, COMPARE >::put_unused(), and AMP::AtomicList< TYPE, COMPARE >::unlock().
|
private |
Definition at line 113 of file AtomicList.h.
|
private |
Definition at line 116 of file AtomicList.h.
Referenced by AMP::AtomicList< TYPE, COMPARE >::get_unused(), and AMP::AtomicList< TYPE, COMPARE >::put_unused().
|
Advanced Multi-Physics (AMP) Oak Ridge National Laboratory Idaho National Laboratory Los Alamos National Laboratory |
This page automatically produced from the source code by Last updated: Tue Mar 10 2026 13:06:42. Comments on this page |