1 #ifndef CORELIB__CACHE_WITH_LOCK__HPP
2 #define CORELIB__CACHE_WITH_LOCK__HPP
40 template<
class Key,
class Value,
class Less = less<Key> >
100 m_Slot->m_LockCounter.Add(1);
105 if (
m_Slot != lock.m_Slot ) {
112 m_Slot->m_LockCounter.Add(1);
124 if (
m_Slot != lock.m_Slot ) {
151 return !(*
this ==
a);
168 iter->second->m_MapIter = iter;
170 else if ( iter->second->m_LockCounter.Add(1) == 1 ) {
177 return CLock(
this, iter->second);
223 template<
class Position,
class Value>
232 return r1.GetToOpen() <
r2.GetToOpen();
290 m_Slot->m_LockCounter.Add(1);
295 if (
m_Slot != lock.m_Slot ) {
302 m_Slot->m_LockCounter.Add(1);
314 if (
m_Slot != lock.m_Slot ) {
342 return !(*
this ==
a);
358 if ( iter !=
m_Map.
end() && iter->first.GetFrom() <= pos ) {
360 if ( iter->second->m_LockCounter.Add(1) == 1 ) {
374 pos >= iter_before->first.GetToOpen());
376 pos < iter->
first.GetFrom());
378 while (
s_Overlaps(pos, size_pow2, iter_before, iter) ) {
386 iter->second->m_MapIter = iter;
388 return CLock(
this, iter);
429 if ( iter_before != iter_after &&
430 iter_before->first.GetToOpen() >
range.GetFrom() ) {
435 iter_after->first.GetFrom() <
range.GetToOpen() ) {
CFastMutex & GetValueMutex()
bool operator==(CLock a) const
CLock & operator=(const CLock &lock)
CRef< CBinaryRangeCacheWithLock > m_Cache
CLock & operator=(CLock &&lock)
DECLARE_OPERATOR_BOOL_REF(m_Slot)
mapped_type & operator*() const
mapped_type * operator->() const
const range_type & get_range() const
CLock(CBinaryRangeCacheWithLock *cache, const TMapIterator &iter)
bool operator!=(CLock a) const
CAtomicCounter m_LockCounter
TRemoveListIterator m_RemoveListIter
map< range_type, CRef< CSlot >, PLess > TMap
TRemoveList::iterator TRemoveListIterator
bool s_Overlaps(position_type pos, position_type size_pow2, TMapIterator iter_before, TMapIterator iter_after) const
void set_size_limit(size_t size_limit)
list< TMapIterator > TRemoveList
CLock get_lock(const position_type &pos, position_type size_pow2)
static range_type s_MakeRange(position_type pos, position_type size_pow2)
CBinaryRangeCacheWithLock(size_t size_limit=0)
TMap::const_iterator TMapConstIterator
COpenRange< position_type > range_type
size_t get_size_limit(void) const
TMap::iterator TMapIterator
CFastMutex & GetValueMutex()
bool operator!=(CLock a) const
DECLARE_OPERATOR_BOOL_REF(m_Slot)
CRef< CCacheWithLock > m_Cache
mapped_type * operator->() const
CLock & operator=(CLock &&lock)
mapped_type & operator*() const
bool operator==(CLock a) const
CLock & operator=(const CLock &lock)
CLock(CCacheWithLock *cache, CSlot *slot)
TRemoveListIterator m_RemoveListIter
CAtomicCounter m_LockCounter
size_t get_size_limit(void) const
list< TMapIterator > TRemoveList
void set_size_limit(size_t size_limit)
CLock get_lock(const key_type &key)
TMap::iterator TMapIterator
map< key_type, CRef< CSlot >, TLess > TMap
CCacheWithLock(size_t size_limit=0)
TMap::const_iterator TMapConstIterator
TRemoveList::iterator TRemoveListIterator
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator lower_bound(const key_type &key) const
iterator_bool insert(const value_type &val)
const_iterator upper_bound(const key_type &key) const
container_type::value_type value_type
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
void Set(TValue new_value) THROWS_NONE
Set atomic counter value.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
void Swap(TThisType &ref)
Swaps the pointer with another reference.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
static const sljit_gpr r1
static const sljit_gpr r2
bool operator()(const range_type &r1, const range_type &r2) const