ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::LockFreePriorityQueue< K, T, Less > Class Template Reference

an exact PRIORITY QUEUE shared by threads, linearizable and lock-free: the skiplist of Lindén and Jonsson, its deleted prefix cut in batches More...

#include <ADS/concurrent/LockFreePriorityQueue.h>

Classes

struct  Entry
 a pair of the queue, its key and its item More...
struct  Counts
 what a handle counted of its operations, for comparisons that do not time: the read-modify-writes, those that failed, the nodes walked by the DeleteMin, and the cuts of the prefix More...
class  Handle
 the access of one thread to a LockFreePriorityQueue: its record of the epochs, the generator of its heights and the counter of its stamps More...

Public types

using Key = K
 the type of the keys
using Item = T
 the type of the items

Public member functions

 LockFreePriorityQueue (unsigned offset=32, std::uint64_t seed=1, Less less=Less())
 the empty queue, whose DeleteMin cut the prefix once they walked more than \( b \) = offset nodes, with the heights drawn from the seed seed
 LockFreePriorityQueue (const LockFreePriorityQueue &)=delete
 no copy, since the threads share it by its address
LockFreePriorityQueue & operator= (const LockFreePriorityQueue &)=delete
 no copy, since the threads share it by its address
 ~LockFreePriorityQueue ()
 the frees of the nodes, of those waiting for their epoch and of the records
Handle handle (void)
 a handle for one thread, on a record of the epochs of its own
unsigned offset (void) const
 the length \( b \) of the prefix past which a DeleteMin cuts it
std::size_t size (void) const
 the number of the pairs, i.e., of the nodes not deleted of level 0; with no operation running
bool empty (void) const
 whether size() is 0; with no operation running
std::size_t prefix (void) const
 the number of the deleted nodes still in the list of level 0; with no operation running
bool consistent (void) const
 the invariants of the lists: the deleted nodes a prefix of level 0, the rest ordered by (key, stamp), each upper level a subsequence of level 0 from the first node of the head, no node being inserted; with no operation running

Static public attributes

static constexpr decrease_key_kind decrease_key = decrease_key_kind::lazy
 a queue with no handles on the pairs, on which a search lowers a key by a new insertion [see decrease_key_of() of Capabilities.h]
static constexpr int kLevels = 32
 the levels of the skiplist

Detailed description

template<class K, class T, class Less = std::less< K >>
class ADS::LockFreePriorityQueue< K, T, Less >

an exact PRIORITY QUEUE shared by threads, linearizable and lock-free: the skiplist of Lindén and Jonsson, its deleted prefix cut in batches

Member typedef documentation

◆ Item

template<class K, class T, class Less = std::less< K >>
using ADS::LockFreePriorityQueue< K, T, Less >::Item = T

the type of the items

◆ Key

template<class K, class T, class Less = std::less< K >>
using ADS::LockFreePriorityQueue< K, T, Less >::Key = K

the type of the keys

Constructor and destructor documentation

◆ LockFreePriorityQueue() [1/2]

template<class K, class T, class Less = std::less< K >>
ADS::LockFreePriorityQueue< K, T, Less >::LockFreePriorityQueue ( unsigned offset = 32,
std::uint64_t seed = 1,
Less less = Less() )
explicit

the empty queue, whose DeleteMin cut the prefix once they walked more than \( b \) = offset nodes, with the heights drawn from the seed seed

Precondition
\( b \ge 1 \)

◆ LockFreePriorityQueue() [2/2]

template<class K, class T, class Less = std::less< K >>
ADS::LockFreePriorityQueue< K, T, Less >::LockFreePriorityQueue ( const LockFreePriorityQueue< K, T, Less > & )
delete

no copy, since the threads share it by its address

◆ ~LockFreePriorityQueue()

template<class K, class T, class Less = std::less< K >>
ADS::LockFreePriorityQueue< K, T, Less >::~LockFreePriorityQueue ( )

the frees of the nodes, of those waiting for their epoch and of the records

Precondition
no handle is alive

Member function documentation

◆ consistent()

template<class K, class T, class Less = std::less< K >>
bool ADS::LockFreePriorityQueue< K, T, Less >::consistent ( void ) const
nodiscard

the invariants of the lists: the deleted nodes a prefix of level 0, the rest ordered by (key, stamp), each upper level a subsequence of level 0 from the first node of the head, no node being inserted; with no operation running

◆ empty()

template<class K, class T, class Less = std::less< K >>
bool ADS::LockFreePriorityQueue< K, T, Less >::empty ( void ) const
nodiscard

whether size() is 0; with no operation running

◆ handle()

template<class K, class T, class Less = std::less< K >>
Handle ADS::LockFreePriorityQueue< K, T, Less >::handle ( void )
nodiscard

a handle for one thread, on a record of the epochs of its own

◆ offset()

template<class K, class T, class Less = std::less< K >>
unsigned ADS::LockFreePriorityQueue< K, T, Less >::offset ( void ) const
inlinenodiscard

the length \( b \) of the prefix past which a DeleteMin cuts it

◆ operator=()

template<class K, class T, class Less = std::less< K >>
LockFreePriorityQueue & ADS::LockFreePriorityQueue< K, T, Less >::operator= ( const LockFreePriorityQueue< K, T, Less > & )
delete

no copy, since the threads share it by its address

◆ prefix()

template<class K, class T, class Less = std::less< K >>
std::size_t ADS::LockFreePriorityQueue< K, T, Less >::prefix ( void ) const
nodiscard

the number of the deleted nodes still in the list of level 0; with no operation running

◆ size()

template<class K, class T, class Less = std::less< K >>
std::size_t ADS::LockFreePriorityQueue< K, T, Less >::size ( void ) const
nodiscard

the number of the pairs, i.e., of the nodes not deleted of level 0; with no operation running

Member data documentation

◆ decrease_key

template<class K, class T, class Less = std::less< K >>
decrease_key_kind ADS::LockFreePriorityQueue< K, T, Less >::decrease_key = decrease_key_kind::lazy
staticconstexpr

a queue with no handles on the pairs, on which a search lowers a key by a new insertion [see decrease_key_of() of Capabilities.h]

◆ kLevels

template<class K, class T, class Less = std::less< K >>
int ADS::LockFreePriorityQueue< K, T, Less >::kLevels = 32
staticconstexpr

the levels of the skiplist


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