CUBRID Engine  latest
lockfree::hashmap< Key, T > Class Template Reference

#include <lockfree_hashmap.hpp>

Inheritance diagram for lockfree::hashmap< Key, T >:
Inheritance graph
Collaboration diagram for lockfree::hashmap< Key, T >:
Collaboration graph

Classes

struct  freelist_node_data
 
class  iterator
 

Public Member Functions

 hashmap ()
 
 ~hashmap ()
 
void init (tran::system &transys, size_t hash_size, size_t freelist_block_size, size_t freelist_block_count, lf_entry_descriptor &edesc)
 
void destroy ()
 
T * find (tran::index tran_index, Key &key)
 
bool find_or_insert (tran::index tran_index, Key &key, T *&entry)
 
bool insert (tran::index tran_index, Key &key, T *&entry)
 
bool insert_given (tran::index tran_index, Key &key, T *&entry)
 
bool erase (tran::index tran_index, Key &key)
 
bool erase_locked (tran::index tran_index, Key &key, T *&locked_entry)
 
void unlock (tran::index tran_index, T *&entry)
 
void clear (tran::index tran_index)
 
T * freelist_claim (tran::index tran_index)
 
void freelist_retire (tran::index tran_index, T *&entry)
 
void start_tran (tran::index tran_index)
 
void end_tran (tran::index tran_index)
 
template<typename D >
void dump_stats (std::ostream &os) const
 
void activate_stats ()
 
void deactivate_stats ()
 
size_t get_size () const
 
size_t get_element_count () const
 

Private Types

using address_type = address_marker< T >
 
using freelist_type = freelist< freelist_node_data >
 
using free_node_type = typename freelist_type::free_node
 
using ct_stat_type = cubmonitor::atomic_counter_timer_stat
 

Private Member Functions

void *volatile * get_ref (T *p, size_t offset)
 
void * get_ptr (T *p, size_t offset)
 
void * get_ptr_deref (T *p, size_t offset)
 
void * get_keyp (T *p)
 
T * get_nextp (T *p)
 
T *& get_nextp_ref (T *p)
 
pthread_mutex_t * get_pthread_mutexp (T *p)
 
free_node_typeto_free_node (T *p)
 
T * from_free_node (free_node_type *fn)
 
void save_temporary (tran::descriptor &tdes, T *&p)
 
T * claim_temporary (tran::descriptor &tdes)
 
T * freelist_claim (tran::descriptor &tdes)
 
void freelist_retire (tran::descriptor &tdes, T *&p)
 
void safeguard_use_mutex_or_tran_started (const tran::descriptor &tdes, const pthread_mutex_t *mtx)
 
void start_tran_if_not_started (tran::descriptor &tdes)
 
void start_tran_force (tran::descriptor &tdes)
 
void promote_tran_force (tran::descriptor &tdes)
 
void end_tran_if_started (tran::descriptor &tdes)
 
void end_tran_force (tran::descriptor &tdes)
 
void lock_entry (T &tolock)
 
void unlock_entry (T &tounlock)
 
void lock_entry_mutex (T &tolock, pthread_mutex_t *&mtx)
 
void unlock_entry_mutex_if_locked (pthread_mutex_t *&mtx)
 
void unlock_entry_mutex_force (pthread_mutex_t *&mtx)
 
size_t get_hash (Key &key) const
 
T *& get_bucket (Key &key)
 
tran::descriptorget_tran_descriptor (tran::index tran_index)
 
void list_find (tran::index tran_index, T *list_head, Key &key, int *behavior_flags, T *&found_node)
 
bool list_insert_internal (tran::index tran_index, T *&list_head, Key &key, int *behavior_flags, T *&found_node)
 
bool list_delete (tran::index tran_index, T *&list_head, Key &key, T *locked_entry, int *behavior_flags)
 
bool hash_insert_internal (tran::index tran_index, Key &key, int bflags, T *&entry)
 
bool hash_erase_internal (tran::index tran_index, Key &key, int bflags, T *locked_entry)
 
template<typename D >
void dump_stat (std::ostream &os, const char *name, const ct_stat_type &ct_stat) const
 

Static Private Member Functions

static constexpr std::ptrdiff_t free_node_offset_of_data (free_node_type fn)
 

Private Attributes

freelist_typem_freelist
 
T ** m_buckets
 
size_t m_size
 
T ** m_backbuffer
 
std::mutex m_backbuffer_mutex
 
lf_entry_descriptorm_edesc
 
ct_stat_type m_stat_find
 
ct_stat_type m_stat_insert
 
ct_stat_type m_stat_erase
 
ct_stat_type m_stat_unlock
 
ct_stat_type m_stat_clear
 
ct_stat_type m_stat_iterates
 
ct_stat_type m_stat_claim
 
ct_stat_type m_stat_retire
 
bool m_active_stats
 

Detailed Description

template<class Key, class T>
class lockfree::hashmap< Key, T >

Definition at line 42 of file lockfree_hashmap.hpp.

Member Typedef Documentation

template<class Key, class T>
using lockfree::hashmap< Key, T >::address_type = address_marker<T>
private

Definition at line 80 of file lockfree_hashmap.hpp.

template<class Key, class T>
using lockfree::hashmap< Key, T >::ct_stat_type = cubmonitor::atomic_counter_timer_stat
private

Definition at line 113 of file lockfree_hashmap.hpp.

template<class Key, class T>
using lockfree::hashmap< Key, T >::free_node_type = typename freelist_type::free_node
private

Definition at line 100 of file lockfree_hashmap.hpp.

template<class Key, class T>
using lockfree::hashmap< Key, T >::freelist_type = freelist<freelist_node_data>
private

Definition at line 99 of file lockfree_hashmap.hpp.

Constructor & Destructor Documentation

template<class Key , class T >
lockfree::hashmap< Key, T >::hashmap ( )

Definition at line 203 of file lockfree_hashmap.hpp.

template<class Key , class T >
lockfree::hashmap< Key, T >::~hashmap ( )

Definition at line 223 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::destroy().

Member Function Documentation

template<class Key , class T >
void lockfree::hashmap< Key, T >::activate_stats ( )

Definition at line 624 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::m_active_stats.

template<class Key , class T >
T * lockfree::hashmap< Key, T >::claim_temporary ( tran::descriptor tdes)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::deactivate_stats ( )

Definition at line 631 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::m_active_stats.

template<class Key , class T >
template<typename D >
void lockfree::hashmap< Key, T >::dump_stat ( std::ostream &  os,
const char *  name,
const ct_stat_type ct_stat 
) const
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::end_tran ( tran::index  tran_index)
template<class Key , class T >
void lockfree::hashmap< Key, T >::end_tran_force ( tran::descriptor tdes)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::end_tran_if_started ( tran::descriptor tdes)
private

Definition at line 733 of file lockfree_hashmap.hpp.

References lockfree::tran::descriptor::end_tran(), and lockfree::tran::descriptor::is_tran_started().

Referenced by lockfree::hashmap< Key, T >::list_insert_internal().

Here is the caller graph for this function:

template<class Key, class T >
bool lockfree::hashmap< Key, T >::erase ( tran::index  tran_index,
Key &  key 
)
template<class Key, class T>
bool lockfree::hashmap< Key, T >::erase_locked ( tran::index  tran_index,
Key &  key,
T *&  locked_entry 
)
template<class Key, class T>
bool lockfree::hashmap< Key, T >::find_or_insert ( tran::index  tran_index,
Key &  key,
T *&  entry 
)
template<class Key, class T>
static constexpr std::ptrdiff_t lockfree::hashmap< Key, T >::free_node_offset_of_data ( free_node_type  fn)
inlinestaticprivate

Definition at line 166 of file lockfree_hashmap.hpp.

Referenced by lockfree::hashmap< Key, T >::to_free_node().

Here is the caller graph for this function:

template<class Key , class T >
T * lockfree::hashmap< Key, T >::freelist_claim ( tran::index  tran_index)

Definition at line 648 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::get_tran_descriptor().

Referenced by lockfree::hashmap< Key, T >::list_insert_internal().

Here is the caller graph for this function:

template<class Key , class T>
void lockfree::hashmap< Key, T >::freelist_retire ( tran::index  tran_index,
T *&  entry 
)
template<class Key , class T >
T * lockfree::hashmap< Key, T >::from_free_node ( free_node_type fn)
private

Definition at line 536 of file lockfree_hashmap.hpp.

References assert, and NULL.

Referenced by lockfree::hashmap< Key, T >::claim_temporary(), and lockfree::hashmap< Key, T >::freelist_claim().

Here is the caller graph for this function:

template<class Key, class T >
T *& lockfree::hashmap< Key, T >::get_bucket ( Key &  key)
private
template<class Key , class T >
size_t lockfree::hashmap< Key, T >::get_element_count ( ) const
template<class Key, class T >
size_t lockfree::hashmap< Key, T >::get_hash ( Key &  key) const
private

Definition at line 462 of file lockfree_hashmap.hpp.

References lf_entry_descriptor::f_hash, lockfree::hashmap< Key, T >::m_edesc, and lockfree::hashmap< Key, T >::m_size.

Referenced by lockfree::hashmap< Key, T >::get_bucket().

Here is the caller graph for this function:

template<class Key , class T>
void * lockfree::hashmap< Key, T >::get_keyp ( T *  p)
private
template<class Key , class T>
T * lockfree::hashmap< Key, T >::get_nextp ( T *  p)
private
template<class Key , class T>
pthread_mutex_t * lockfree::hashmap< Key, T >::get_pthread_mutexp ( T *  p)
private
template<class Key , class T>
void * lockfree::hashmap< Key, T >::get_ptr ( T *  p,
size_t  offset 
)
private

Definition at line 483 of file lockfree_hashmap.hpp.

References assert, lockfree::address_marker< T >::is_address_marked(), and NULL.

Referenced by lockfree::hashmap< Key, T >::get_keyp(), and lockfree::hashmap< Key, T >::get_pthread_mutexp().

Here is the caller graph for this function:

template<class Key , class T>
void * lockfree::hashmap< Key, T >::get_ptr_deref ( T *  p,
size_t  offset 
)
private

Definition at line 501 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::get_ref().

Referenced by lockfree::hashmap< Key, T >::get_nextp().

Here is the caller graph for this function:

template<class Key , class T>
void *volatile * lockfree::hashmap< Key, T >::get_ref ( T *  p,
size_t  offset 
)
private

Definition at line 492 of file lockfree_hashmap.hpp.

References assert, lockfree::address_marker< T >::is_address_marked(), and NULL.

Referenced by lockfree::hashmap< Key, T >::get_nextp_ref(), and lockfree::hashmap< Key, T >::get_ptr_deref().

Here is the caller graph for this function:

template<class Key , class T >
size_t lockfree::hashmap< Key, T >::get_size ( void  ) const

Definition at line 448 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::m_size.

template<class Key, class T>
bool lockfree::hashmap< Key, T >::hash_erase_internal ( tran::index  tran_index,
Key &  key,
int  bflags,
T *  locked_entry 
)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::init ( tran::system transys,
size_t  hash_size,
size_t  freelist_block_size,
size_t  freelist_block_count,
lf_entry_descriptor edesc 
)
template<class Key, class T>
bool lockfree::hashmap< Key, T >::insert ( tran::index  tran_index,
Key &  key,
T *&  entry 
)
template<class Key, class T>
bool lockfree::hashmap< Key, T >::insert_given ( tran::index  tran_index,
Key &  key,
T *&  entry 
)
template<class Key, class T>
bool lockfree::hashmap< Key, T >::list_insert_internal ( tran::index  tran_index,
T *&  list_head,
Key &  key,
int *  behavior_flags,
T *&  found_node 
)
private
template<class Key , class T>
void lockfree::hashmap< Key, T >::lock_entry ( T &  tolock)
private

Definition at line 751 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::lock_entry_mutex(), and NULL.

Referenced by lockfree::hashmap< Key, T >::iterator::iterate().

Here is the caller graph for this function:

template<class Key , class T >
void lockfree::hashmap< Key, T >::promote_tran_force ( tran::descriptor tdes)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::safeguard_use_mutex_or_tran_started ( const tran::descriptor tdes,
const pthread_mutex_t *  mtx 
)
private
template<class Key , class T>
void lockfree::hashmap< Key, T >::save_temporary ( tran::descriptor tdes,
T *&  p 
)
private

Definition at line 555 of file lockfree_hashmap.hpp.

References NULL, lockfree::tran::descriptor::save_reclaimable(), and lockfree::hashmap< Key, T >::to_free_node().

Referenced by lockfree::hashmap< Key, T >::list_insert_internal().

Here is the caller graph for this function:

template<class Key , class T >
void lockfree::hashmap< Key, T >::start_tran ( tran::index  tran_index)
template<class Key , class T >
void lockfree::hashmap< Key, T >::start_tran_force ( tran::descriptor tdes)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::start_tran_if_not_started ( tran::descriptor tdes)
private

Definition at line 710 of file lockfree_hashmap.hpp.

References lockfree::tran::descriptor::start_tran().

template<class Key , class T>
hashmap< Key, T >::freelist_type::free_node * lockfree::hashmap< Key, T >::to_free_node ( T *  p)
private
template<class Key , class T>
void lockfree::hashmap< Key, T >::unlock_entry ( T &  tounlock)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::unlock_entry_mutex_force ( pthread_mutex_t *&  mtx)
private
template<class Key , class T >
void lockfree::hashmap< Key, T >::unlock_entry_mutex_if_locked ( pthread_mutex_t *&  mtx)
private

Definition at line 781 of file lockfree_hashmap.hpp.

References lockfree::hashmap< Key, T >::m_edesc, NULL, pthread_mutex_unlock, and lf_entry_descriptor::using_mutex.

Referenced by lockfree::hashmap< Key, T >::list_insert_internal().

Here is the caller graph for this function:

Member Data Documentation

template<class Key, class T>
T** lockfree::hashmap< Key, T >::m_backbuffer
private
template<class Key, class T>
std::mutex lockfree::hashmap< Key, T >::m_backbuffer_mutex
private

Definition at line 108 of file lockfree_hashmap.hpp.

Referenced by lockfree::hashmap< Key, T >::clear().

template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_claim
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_clear
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_erase
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_find
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_insert
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_iterates
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_retire
private
template<class Key, class T>
ct_stat_type lockfree::hashmap< Key, T >::m_stat_unlock
private

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