CUBRID Engine  latest
lockfree::circular_queue< T > Class Template Reference

#include <lockfree_circular_queue.hpp>

Inheritance diagram for lockfree::circular_queue< T >:
Inheritance graph
Collaboration diagram for lockfree::circular_queue< T >:
Collaboration graph

Public Types

using cursor_type = std::uint64_t
 
using atomic_cursor_type = std::atomic< cursor_type >
 
using data_type = T
 
using atomic_flag_type = atomic_cursor_type
 

Public Member Functions

 circular_queue (std::size_t size)
 
 ~circular_queue ()
 
bool is_empty () const
 
bool is_full () const
 
bool is_half_full ()
 
std::size_t size ()
 
bool consume (T &element)
 
bool produce (const T &element)
 
void force_produce (const T &element)
 
std::uint64_t get_consumer_cursor ()
 

Private Member Functions

 circular_queue ()
 
 circular_queue (const circular_queue &)
 
std::size_t next_pow2 (std::size_t size) const
 
bool test_empty_cursors (cursor_type produce_cursor, cursor_type consume_cursor) const
 
bool test_full_cursors (cursor_type produce_cursor, cursor_type consume_cursor) const
 
cursor_type load_cursor (atomic_cursor_type &cursor)
 
bool test_and_increment_cursor (atomic_cursor_type &cursor, cursor_type crt_value)
 
load_data (cursor_type consume_cursor) const
 
void store_data (cursor_type index, const T &data)
 
std::size_t get_cursor_index (cursor_type cursor) const
 
bool is_blocked (cursor_type cursor) const
 
bool block (cursor_type cursor)
 
void unblock (cursor_type cursor)
 
void init_blocked_cursors (void)
 

Private Attributes

data_typem_data
 
atomic_flag_typem_blocked_cursors
 
atomic_cursor_type m_produce_cursor
 
atomic_cursor_type m_consume_cursor
 
std::size_t m_capacity
 
std::size_t m_index_mask
 

Static Private Attributes

static const cursor_type BLOCK_FLAG
 

Detailed Description

template<class T>
class lockfree::circular_queue< T >

Definition at line 46 of file lockfree_circular_queue.hpp.

Member Typedef Documentation

template<class T>
using lockfree::circular_queue< T >::atomic_cursor_type = std::atomic<cursor_type>

Definition at line 50 of file lockfree_circular_queue.hpp.

Definition at line 52 of file lockfree_circular_queue.hpp.

template<class T>
using lockfree::circular_queue< T >::cursor_type = std::uint64_t

Definition at line 49 of file lockfree_circular_queue.hpp.

template<class T>
using lockfree::circular_queue< T >::data_type = T

Definition at line 51 of file lockfree_circular_queue.hpp.

Constructor & Destructor Documentation

template<class T>
lockfree::circular_queue< T >::circular_queue ( )
private
template<class T>
lockfree::circular_queue< T >::circular_queue ( const circular_queue< T > &  )
private

Member Function Documentation

template<class T>
void lockfree::circular_queue< T >::force_produce ( const T &  element)
inline
template<class T >
std::uint64_t lockfree::circular_queue< T >::get_consumer_cursor ( )
inline

Definition at line 311 of file lockfree_circular_queue.hpp.

References lockfree::circular_queue< T >::m_consume_cursor.

Referenced by pgbuf_get_victim().

Here is the caller graph for this function:

template<class T >
bool lockfree::circular_queue< T >::is_full ( ) const
inline
template<class T >
bool lockfree::circular_queue< T >::is_half_full ( )
inline
template<class T >
T lockfree::circular_queue< T >::load_data ( cursor_type  consume_cursor) const
inlineprivate
template<class T >
std::size_t lockfree::circular_queue< T >::next_pow2 ( std::size_t  size) const
inlineprivate

Definition at line 409 of file lockfree_circular_queue.hpp.

Referenced by lockfree::circular_queue< T >::circular_queue().

Here is the caller graph for this function:

template<class T >
std::size_t lockfree::circular_queue< T >::size ( )
inline
template<class T>
void lockfree::circular_queue< T >::store_data ( cursor_type  index,
const T &  data 
)
inlineprivate
template<class T >
bool lockfree::circular_queue< T >::test_and_increment_cursor ( atomic_cursor_type cursor,
cursor_type  crt_value 
)
inlineprivate
template<class T >
bool lockfree::circular_queue< T >::test_empty_cursors ( cursor_type  produce_cursor,
cursor_type  consume_cursor 
) const
inlineprivate

Definition at line 420 of file lockfree_circular_queue.hpp.

Referenced by lockfree::circular_queue< T >::consume(), and lockfree::circular_queue< T >::is_empty().

Here is the caller graph for this function:

template<class T >
bool lockfree::circular_queue< T >::test_full_cursors ( cursor_type  produce_cursor,
cursor_type  consume_cursor 
) const
inlineprivate

Member Data Documentation

template<class T>
circular_queue< T >::cursor_type const lockfree::circular_queue< T >::BLOCK_FLAG
staticprivate
template<class T>
std::size_t lockfree::circular_queue< T >::m_index_mask
private

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