Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AMP::AtomicList< TYPE, COMPARE > Class Template Referencefinal

Maintain a sorted list of entries. More...

#include <AtomicList.h>

Inheritance diagram for AMP::AtomicList< TYPE, COMPARE >:
Inheritance graph
[legend]

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.
 
AtomicListoperator= (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
 

Detailed Description

template<class TYPE, class COMPARE = std::less<TYPE>>
class AMP::AtomicList< TYPE, COMPARE >

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.

Constructor & Destructor Documentation

◆ AtomicList() [1/2]

template<class TYPE , class COMPARE = std::less<TYPE>>
AMP::AtomicList< TYPE, COMPARE >::AtomicList ( size_t  capacity = 1024,
const TYPE &  default_value = TYPE(),
const COMPARE &  comp = COMPARE() 
)

Default constructor.

◆ ~AtomicList()

template<class TYPE , class COMPARE = std::less<TYPE>>
AMP::AtomicList< TYPE, COMPARE >::~AtomicList ( )

Destructor.

◆ AtomicList() [2/2]

template<class TYPE , class COMPARE = std::less<TYPE>>
AMP::AtomicList< TYPE, COMPARE >::AtomicList ( const AtomicList< TYPE, COMPARE > &  )
delete

Member Function Documentation

◆ available()

template<class TYPE , class COMPARE = std::less<TYPE>>
constexpr size_t AMP::AtomicList< TYPE, COMPARE >::available ( ) const
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().

◆ capacity()

template<class TYPE , class COMPARE = std::less<TYPE>>
constexpr size_t AMP::AtomicList< TYPE, COMPARE >::capacity ( ) const
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().

◆ check()

template<class TYPE , class COMPARE = std::less<TYPE>>
bool AMP::AtomicList< TYPE, COMPARE >::check ( )
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!

Returns
This function returns true if the list is in a good working state

◆ clear()

template<class TYPE , class COMPARE = std::less<TYPE>>
void AMP::AtomicList< TYPE, COMPARE >::clear ( )
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().

◆ empty()

template<class TYPE , class COMPARE = std::less<TYPE>>
bool AMP::AtomicList< TYPE, COMPARE >::empty ( ) const
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().

◆ get_unused()

template<class TYPE , class COMPARE = std::less<TYPE>>
int AMP::AtomicList< TYPE, COMPARE >::get_unused ( )
inlineprivate

◆ insert()

template<class TYPE , class COMPARE = std::less<TYPE>>
void AMP::AtomicList< TYPE, COMPARE >::insert ( const TYPE &  x)
inline

Insert an item.

Insert an item into the list

Parameters
xItem to insert

Referenced by AMP::ThreadPoolListQueue::changePriorities(), and AMP::ThreadPoolListQueue::insert().

◆ lock()

template<class TYPE , class COMPARE = std::less<TYPE>>
int AMP::AtomicList< TYPE, COMPARE >::lock ( int  i)
inlineprivate

Definition at line 121 of file AtomicList.h.

References AMP::AtomicList< TYPE, COMPARE >::d_next.

◆ N_insert()

template<class TYPE , class COMPARE = std::less<TYPE>>
size_t AMP::AtomicList< TYPE, COMPARE >::N_insert ( ) const
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.

◆ N_remove()

template<class TYPE , class COMPARE = std::less<TYPE>>
size_t AMP::AtomicList< TYPE, COMPARE >::N_remove ( ) const
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.

◆ operator=()

template<class TYPE , class COMPARE = std::less<TYPE>>
AtomicList & AMP::AtomicList< TYPE, COMPARE >::operator= ( const AtomicList< TYPE, COMPARE > &  )
delete

◆ put_unused()

template<class TYPE , class COMPARE = std::less<TYPE>>
void AMP::AtomicList< TYPE, COMPARE >::put_unused ( int  i)
inlineprivate

◆ remove()

template<class TYPE , class COMPARE = std::less<TYPE>>
template<typename Compare , class... Args>
TYPE AMP::AtomicList< TYPE, COMPARE >::remove ( Compare  compare,
const Args &...  args 
)
inline

Remove an item from the list.

Find and remove first entry that meets the given criteria

Returns
Return the item that matches the criteria, or the default item if no item matches
Parameters
compareComparison 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, ... );
argsAdditional arguments for the comparison

Referenced by AMP::ThreadPoolListQueue::changePriorities(), and AMP::ThreadPoolListQueue::pop().

◆ remove_first()

template<class TYPE , class COMPARE = std::less<TYPE>>
TYPE AMP::AtomicList< TYPE, COMPARE >::remove_first ( )
inline

Remove the first from the list.

Referenced by AMP::AtomicList< TYPE, COMPARE >::clear().

◆ size()

template<class TYPE , class COMPARE = std::less<TYPE>>
size_t AMP::AtomicList< TYPE, COMPARE >::size ( ) const
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().

◆ unlock()

template<class TYPE , class COMPARE = std::less<TYPE>>
void AMP::AtomicList< TYPE, COMPARE >::unlock ( int  i,
int  value 
)
inlineprivate

Definition at line 131 of file AtomicList.h.

References AMP::AtomicList< TYPE, COMPARE >::d_next.

Member Data Documentation

◆ d_capacity

template<class TYPE , class COMPARE = std::less<TYPE>>
const size_t AMP::AtomicList< TYPE, COMPARE >::d_capacity
private

◆ d_compare

template<class TYPE , class COMPARE = std::less<TYPE>>
COMPARE AMP::AtomicList< TYPE, COMPARE >::d_compare
private

Definition at line 110 of file AtomicList.h.

◆ d_default

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile TYPE AMP::AtomicList< TYPE, COMPARE >::d_default
private

Definition at line 112 of file AtomicList.h.

◆ d_N

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile std::atomic_int32_t AMP::AtomicList< TYPE, COMPARE >::d_N
private

◆ d_N_insert

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile std::atomic_int64_t AMP::AtomicList< TYPE, COMPARE >::d_N_insert
private

Definition at line 117 of file AtomicList.h.

Referenced by AMP::AtomicList< TYPE, COMPARE >::N_insert().

◆ d_N_remove

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile std::atomic_int64_t AMP::AtomicList< TYPE, COMPARE >::d_N_remove
private

Definition at line 118 of file AtomicList.h.

Referenced by AMP::AtomicList< TYPE, COMPARE >::N_remove().

◆ d_next

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile std::atomic_int32_t* AMP::AtomicList< TYPE, COMPARE >::d_next
private

◆ d_objects

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile TYPE* AMP::AtomicList< TYPE, COMPARE >::d_objects
private

Definition at line 113 of file AtomicList.h.

◆ d_unused

template<class TYPE , class COMPARE = std::less<TYPE>>
volatile std::atomic_int32_t AMP::AtomicList< TYPE, COMPARE >::d_unused
private

The documentation for this class was generated from the following file:



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page