TARAXA
taraxa::StatusTable< K, V > Class Template Reference

#include <util.hpp>

Collaboration diagram for taraxa::StatusTable< K, V >:

Public Types

using UnsafeStatusTable = std::unordered_map< K, V >
 

Public Member Functions

 StatusTable (size_t capacity=10000)
 
std::pair< V, bool > get (K const &hash)
 
unsigned long size () const
 
bool insert (K const &hash, V status)
 
void update (K const &hash, V status)
 
bool update (K const &hash, V status, V expected_status)
 
void clear ()
 
bool erase (K const &hash)
 
UnsafeStatusTable getThreadUnsafeCopy () const
 

Private Types

using Element = std::list< std::pair< K, V > >
 

Private Member Functions

void clearOldData ()
 

Private Attributes

size_t capacity_
 
std::shared_mutex shared_mutex_
 
std::unordered_map< K, typename std::list< std::pair< K, V > >::iterator > status_
 
std::list< std::pair< K, V > > lru_
 

Detailed Description

template<typename K, typename V>
class taraxa::StatusTable< K, V >

simple thread_safe hash LRU

Member Typedef Documentation

◆ Element

template<typename K , typename V >
using taraxa::StatusTable< K, V >::Element = std::list<std::pair<K, V> >
private

◆ UnsafeStatusTable

template<typename K , typename V >
using taraxa::StatusTable< K, V >::UnsafeStatusTable = std::unordered_map<K, V>

Constructor & Destructor Documentation

◆ StatusTable()

template<typename K , typename V >
taraxa::StatusTable< K, V >::StatusTable ( size_t  capacity = 10000)
inline

Member Function Documentation

◆ clear()

template<typename K , typename V >
void taraxa::StatusTable< K, V >::clear ( )
inline

◆ clearOldData()

template<typename K , typename V >
void taraxa::StatusTable< K, V >::clearOldData ( )
inlineprivate

◆ erase()

template<typename K , typename V >
bool taraxa::StatusTable< K, V >::erase ( K const &  hash)
inline

◆ get()

template<typename K , typename V >
std::pair<V, bool> taraxa::StatusTable< K, V >::get ( K const &  hash)
inline

◆ getThreadUnsafeCopy()

template<typename K , typename V >
UnsafeStatusTable taraxa::StatusTable< K, V >::getThreadUnsafeCopy ( ) const
inline

◆ insert()

template<typename K , typename V >
bool taraxa::StatusTable< K, V >::insert ( K const &  hash,
status 
)
inline

◆ size()

template<typename K , typename V >
unsigned long taraxa::StatusTable< K, V >::size ( ) const
inline

◆ update() [1/2]

template<typename K , typename V >
void taraxa::StatusTable< K, V >::update ( K const &  hash,
status 
)
inline

◆ update() [2/2]

template<typename K , typename V >
bool taraxa::StatusTable< K, V >::update ( K const &  hash,
status,
expected_status 
)
inline

Member Data Documentation

◆ capacity_

template<typename K , typename V >
size_t taraxa::StatusTable< K, V >::capacity_
private

◆ lru_

template<typename K , typename V >
std::list<std::pair<K, V> > taraxa::StatusTable< K, V >::lru_
private

◆ shared_mutex_

template<typename K , typename V >
std::shared_mutex taraxa::StatusTable< K, V >::shared_mutex_
mutableprivate

◆ status_

template<typename K , typename V >
std::unordered_map<K, typename std::list<std::pair<K, V> >::iterator> taraxa::StatusTable< K, V >::status_
private

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