NCBI C++ ToolKit
info_cache.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GENBANK_IMPL_INFO_CACHE
2 #define GENBANK_IMPL_INFO_CACHE
3 
4 /* $Id: info_cache.hpp 101581 2024-01-08 18:09:48Z vasilche $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * GenBank data loader in-memory cache
33 *
34 * ===========================================================================
35 */
36 
37 #include <corelib/ncbistd.hpp>
38 #include <corelib/ncbimtx.hpp>
39 #include <corelib/ncbiobj.hpp>
40 #include <corelib/ncbitime.hpp>
41 
42 #include <list>
43 #include <set>
44 #include <map>
45 #include <unordered_map>
46 
49 BEGIN_SCOPE(GBL)
50 
51 
52 #define USE_MAIN_MUTEX_IN_CACHE 0
53 #define USE_MAIN_MUTEX_FOR_DATA 0
54 
55 class CInfo_Base;
56 class CInfoLock_Base;
57 class CInfoCache_Base;
58 class CInfoManager;
59 class CInfoRequestor;
60 class CInfoRequestorLock;
61 
63 {
64 public:
66 
67 private:
68  // prevent copying
69  INoCopying(const INoCopying&) = delete;
70  void operator=(const INoCopying&) = delete;
71 };
72 
73 enum EDoNotWait {
76 };
77 
81 };
82 
83 class CLoadMutex : public CObject, public CMutex // CFastMutex
84 {
85 public:
86  CLoadMutex(void)
88  {
89  }
90 
91  bool IsLoading(void) const
92  {
93  return m_LoadingRequestor != 0;
94  }
95 
96 protected:
97  friend class CInfoManager;
98  friend class CInfoRequestor;
99  friend class CInfoRequestorLock;
100 
101  atomic<CInfoRequestor*> m_LoadingRequestor;
102 };
103 
104 
106 {
107 public:
108  typedef Uint4 TExpirationTime; // UTC time, seconds since epoch (1970)
109  typedef int TUseCounter;
110  typedef list< CRef<CInfo_Base> > TGCQueue;
111 
112  explicit CInfo_Base(TGCQueue& gc_queue);
113  virtual ~CInfo_Base(void);
114 
115  bool IsLoaded(TExpirationTime expiration_time) const;
116  bool IsLoaded(CInfoRequestor& requestor) const;
118  {
119  return m_ExpirationTime;
120  }
121 
122 protected:
123  friend class CInfoRequestorLock;
124  friend class CInfoCache_Base;
125  friend class CInfoManager;
126  friend class CInfoRequestor;
127 
128  // info usage counter for garbage collector
130  // info expiration UTC time, seconds is actual until this time
131  atomic<TExpirationTime> m_ExpirationTime;
132  CRef<CLoadMutex> m_LoadMutex; // mutex for loading info
133  TGCQueue::iterator m_GCQueuePos; // pos in GC queue if info is not used
134 };
135 
136 
137 // CInfoRequestorLock is a lock within a single requesting thread.
138 // There is no MT-safety required when operating on the CInfoRequestorLock.
139 // It holds MT-lock for the loaded info object.
141 {
142 public:
144  ~CInfoRequestorLock(void);
145 
146 protected:
147  friend class CInfoLock_Base;
148  friend class CInfoCache_Base;
149  friend class CInfoRequestor;
150  friend class CInfoManager;
152 
153  CInfo_Base& GetInfo(void) const
154  {
155  return m_Info.GetNCObject();
156  }
157 
159  {
160  return m_Requestor;
161  }
163  CInfoManager& GetManager(void) const;
164 
165  bool IsLocked(void) const
166  {
167  return m_Mutex.NotNull();
168  }
169 
170  bool IsLoaded(void) const;
171  bool SetLoadedFor(TExpirationTime new_expiration_time);
174  {
175  return GetInfo().GetExpirationTime();
176  }
177 
178  typedef CMutex TMainMutex; // CFastMutex
180  TExpirationTime new_expiration_time);
183 
187 };
188 
189 
191 {
192 public:
193  CInfoManager(void);
194  virtual ~CInfoManager(void);
195 
196  typedef CMutex TMainMutex; // CFastMutex
198  {
199  return m_MainMutex;
200  }
201 
202  void ReleaseAllLoadLocks(CInfoRequestor& requestor);
204 
205 protected:
206  friend class CInfoRequestor;
207  friend class CInfoRequestorLock;
208  friend class CInfoCache_Base;
209 
211  CInfoRequestorLock& lock);
212  bool x_DeadLock(const CInfoRequestor& requestor,
213  const CInfo_Base& info) const;
214 
215  void x_AssignLoadMutex(CRef<CLoadMutex>& mutex);
217 
220 
223 
226  CInfoRequestorLock& lock,
227  EDoNotWait do_not_wait);
229  EDoNotWait do_not_wait);
230 
231  typedef vector< CRef<CLoadMutex> > TLoadMutexPool;
232 
236 };
237 
238 
240 {
241 public:
242  explicit CInfoRequestor(CInfoManager& manager);
243  virtual ~CInfoRequestor(void);
244 
246  {
248  }
249 
251  virtual TExpirationTime GetRequestTime(void) const = 0;
253 
254 protected:
255  friend class CInfoManager;
256  friend class CInfoRequestorLock;
257  friend class CInfoCache_Base;
258 
260  {
261  return m_Manager.GetNCObject();
262  }
263 
264  void ReleaseAllUsedInfos(void);
265 
267  {
268  GetManager().ReleaseLoadLock(lock);
269  }
270 
272  CInfo_Base& info);
273 
274  struct PtrHash {
275  size_t operator()(const void* ptr) const {
276  return size_t(ptr)>>3;
277  }
278  };
279  typedef unordered_map<CInfo_Base*, CRef<CInfoRequestorLock>, PtrHash> TLockMap;
280  typedef unordered_map<CInfoCache_Base*, vector<CInfo_Base*>, PtrHash> TCacheMap;
281 
283  TLockMap m_LockMap; // map from CInfo_Base -> CInfoRequestorLock
284  TCacheMap m_CacheMap; // map of used infos
285 
286  //set< CRef<CInfo_Base> > m_LockedInfos;
288 };
289 
290 
291 inline
292 bool CInfo_Base::IsLoaded(TExpirationTime expiration_time) const
293 {
294  return GetExpirationTime() >= expiration_time;
295 }
296 
297 
298 inline
299 bool CInfo_Base::IsLoaded(CInfoRequestor& requestor) const
300 {
301  return IsLoaded(requestor.GetRequestTime());
302 }
303 
304 
305 inline
307 {
308  return GetInfo().IsLoaded(GetRequestor());
309 }
310 
311 
312 inline
315 {
317 }
318 
319 
320 inline
322 {
324 }
325 
326 
327 inline
330 {
331  return x_SetLoadedFor(guard, GetNewExpirationTime(type));
332 }
333 
334 
335 inline
337 {
338  return GetRequestor().GetManager();
339 }
340 
341 
343 {
344 public:
346 
347  bool IsLocked(void) const
348  {
349  return m_Lock->IsLocked();
350  }
351 
352  bool IsLoaded(void) const
353  {
354  return m_Lock->IsLoaded();
355  }
356  bool SetLoadedFor(TExpirationTime expiration_time)
357  {
358  return m_Lock->SetLoadedFor(expiration_time);
359  }
361  {
362  return m_Lock->SetLoaded(type);
363  }
365  {
366  return m_Lock->GetExpirationTime();
367  }
369  {
371  }
372 
374  {
375  return m_Lock->GetRequestor();
376  }
377 
379 
380 protected:
381  friend class CInfoManager;
382  friend class CInfoCache_Base;
383 
384 #if USE_MAIN_MUTEX_FOR_DATA
386  TDataMutex& GetDataLock(void) const
387  {
388  return m_Lock->GetManager().GetMainMutex();
389  }
391  TExpirationTime expiration_time)
392  {
393  return m_Lock->x_SetLoadedFor(guard, expiration_time);
394  }
397  {
398  return m_Lock->x_SetLoaded(guard, type);
399  }
400 #else
401  typedef CMutex TDataMutex; // CFastMutex
403  SSystemMutex& GetDataLock(void) const
404  {
405  return sm_DataMutex;
406  }
408  TExpirationTime expiration_time)
409  {
410  return m_Lock->SetLoadedFor(expiration_time);
411  }
414  {
415  return m_Lock->SetLoaded(type);
416  }
417 #endif
418 
419  CInfo_Base& GetInfo(void) const
420  {
421  return m_Lock->GetInfo();
422  }
423 
425 };
426 
428 {
429 public:
430  enum {
431  kDefaultMaxSize = 10240
432  };
433 
434  explicit CInfoCache_Base(CInfoManager::TMainMutex& mutex);
435  CInfoCache_Base(CInfoManager::TMainMutex& mutex, size_t max_size);
436  virtual ~CInfoCache_Base(void);
437 
438  size_t GetMaxGCQueueSize(void) const
439  {
440  return m_MaxGCQueueSize;
441  }
442 
443  void SetMaxGCQueueSize(size_t max_size);
444 
445 protected:
446  friend class CInfoLock_Base;
447  friend class CInfoManager;
448  friend class CInfoRequestor;
449 
451 #if USE_MAIN_MUTEX_IN_CACHE
452  typedef TMainMutex TCacheMutex;
454 #else
455  typedef CMutex TCacheMutex; // CFastMutex
457 #endif
458 
459  // mark info as used and set it into CInfoLock_Base
460  void x_SetInfo(CInfoLock_Base& lock,
461  CInfoRequestor& requestor,
462  CInfo_Base& info);
463 
464  // try to acquire lock or leave it unlocked if deadlock is possible
465 #if USE_MAIN_MUTEX_IN_CACHE
467  CInfoRequestorLock& lock,
468  EDoNotWait do_not_wait)
469  {
470  lock.GetManager().x_AcquireLoadLock(guard, lock, do_not_wait);
471  }
472 #else
474  CInfoRequestorLock& lock,
475  EDoNotWait do_not_wait)
476  {
477  guard.Release();
478  lock.GetManager().x_AcquireLoadLock(lock, do_not_wait);
479  }
480 #endif
482  CInfoLock_Base& lock,
483  EDoNotWait do_not_wait)
484  {
485  x_AcquireLoadLock(guard, *lock.m_Lock, do_not_wait);
486  }
487 
488  bool x_Check(const vector<const CInfo_Base*>& infos) const;
489 
490  void ReleaseInfos(const vector<CInfo_Base*>& infos);
491 
492  void x_SetUsed(CInfo_Base& info);
493  void x_SetUnused(CInfo_Base& info);
494 
497 
498  void x_GC(void);
499 
500  virtual void x_ForgetInfo(CInfo_Base& info) = 0;
501 
503 
506 };
507 
508 
509 template<class DataType> class CInfoLock;
510 
511 template<class DataType>
513 {
514 public:
515  typedef DataType TData;
516 
517 protected:
518  friend class CInfoLock<TData>;
519 
520  explicit CInfo_DataBase(typename CInfo_Base::TGCQueue& gc_queue)
521  : CInfo_Base(gc_queue)
522  {
523  }
524 
526 };
527 
528 
529 template<class DataType>
530 class CInfoLock : public CInfoLock_Base
531 {
532 public:
534  typedef DataType TData;
535 
536  TData GetData(void) const
537  {
539  return GetInfo().m_Data;
540  }
542  {
544  bool changed = x_SetLoaded(guard, type);
545  if ( changed ) {
546  GetInfo().m_Data = data;
547  }
548  return changed;
549  }
550  bool SetLoadedFor(const TData& data, TExpirationTime expiration_time)
551  {
553  bool changed = x_SetLoadedFor(guard, expiration_time);
554  if ( changed ) {
555  GetInfo().m_Data = data;
556  }
557  return changed;
558  }
559 
560 protected:
561  TInfo& GetInfo(void) const
562  {
563  return static_cast<TInfo&>(CInfoLock_Base::GetInfo());
564  }
565 };
566 
567 
568 
569 template<class KeyType, class DataType>
571 {
572 public:
573  typedef KeyType key_type;
574  typedef DataType data_type;
576 
578  : CInfoCache_Base(mutex)
579  {
580  }
581  CInfoCache(CInfoManager::TMainMutex& mutex, size_t max_size)
582  : CInfoCache_Base(mutex, max_size)
583  {
584  }
586  {
587  }
588 
589  class CInfo : public CInfo_DataBase<DataType>
590  {
591  public:
592  typedef KeyType TKey;
593 
594  const TKey& GetKey(void) const
595  {
596  return m_Key;
597  }
598 
599  protected:
600  friend class CInfoCache;
601  CInfo(typename CInfo_Base::TGCQueue& gc_queue, const TKey& key)
602  : CInfo_DataBase<DataType>(gc_queue),
603  m_Key(key)
604  {
605  }
606 
607 
609  };
610 
611  typedef CInfo TInfo;
613 
614  bool IsLoaded(CInfoRequestor& requestor,
615  const key_type& key)
616  {
618  _ASSERT(x_Check());
619  typename TIndex::iterator iter = m_Index.find(key);
620  return iter != m_Index.end() && iter->second->IsLoaded(requestor);
621  }
622  bool MarkLoading(CInfoRequestor& requestor,
623  const key_type& key)
624  {
625  return !GetLoadLock(requestor, key).IsLoaded();
626  }
628  const key_type& key,
629  EDoNotWait do_not_wait = eAllowWaiting)
630  {
631  TInfoLock lock;
633  _ASSERT(x_Check());
634  CRef<CInfo>& slot = m_Index[key];
635  if ( !slot ) {
636  // new slot
637  slot = new CInfo(m_GCQueue, key);
638  }
639  x_SetInfo(lock, requestor, *slot);
640  x_AcquireLoadLock(guard, lock, do_not_wait);
641  _ASSERT(x_Check());
642  return lock;
643  }
644  bool SetLoaded(CInfoRequestor& requestor,
645  const key_type& key,
646  const data_type& value,
648  {
650  _ASSERT(x_Check());
651  CRef<CInfo>& slot = m_Index[key];
652  if ( !slot ) {
653  // new slot
654  slot = new CInfo(m_GCQueue, key);
655  }
656  TInfoLock lock;
657  x_SetInfo(lock, requestor, *slot);
658  _ASSERT(x_Check());
659  return lock.SetLoaded(value, type);
660  }
661  bool SetLoadedFor(CInfoRequestor& requestor,
662  const key_type& key,
663  const data_type& value,
664  TExpirationTime expiration_time)
665  {
667  _ASSERT(x_Check());
668  CRef<CInfo>& slot = m_Index[key];
669  if ( !slot ) {
670  // new slot
671  slot = new CInfo(m_GCQueue, key);
672  }
673  TInfoLock lock;
674  x_SetInfo(lock, requestor, *slot);
675  _ASSERT(x_Check());
676  return lock.SetLoadedFor(value, expiration_time);
677  }
679  const key_type& key)
680  {
681  TInfoLock lock;
683  _ASSERT(x_Check());
684  typename TIndex::iterator iter = m_Index.find(key);
685  if ( iter != m_Index.end() &&
686  iter->second->IsLoaded(requestor) ) {
687  x_SetInfo(lock, requestor, *iter->second);
688  }
689  _ASSERT(x_Check());
690  return lock;
691  }
692 
693 protected:
694  friend class CInfoLock_Base;
695 
696 
697  bool x_Check(void) const
698  {
699  return true;
700  vector<const CInfo_Base*> infos;
701  ITERATE ( typename TIndex, it, m_Index ) {
702  infos.push_back(it->second);
703  }
704  return CInfoCache_Base::x_Check(infos);
705  }
706 
707 
708  virtual void x_ForgetInfo(CInfo_Base& info_base)
709  {
710  _ASSERT(dynamic_cast<TInfo*>(&info_base));
711  _VERIFY(m_Index.erase(static_cast<TInfo&>(info_base).GetKey()));
712  }
713 
714 private:
716 
718 };
719 
720 
721 END_SCOPE(GBL)
724 
725 #endif // GENBANK_IMPL_INFO_CACHE
CFastMutex –.
Definition: ncbimtx.hpp:667
void Release()
Manually force the resource to be released.
Definition: guard.hpp:166
CInfo(typename CInfo_Base::TGCQueue &gc_queue, const TKey &key)
Definition: info_cache.hpp:601
const TKey & GetKey(void) const
Definition: info_cache.hpp:594
void x_SetInfo(CInfoLock_Base &lock, CInfoRequestor &requestor, CInfo_Base &info)
Definition: info_cache.cpp:472
void ReleaseInfos(const vector< CInfo_Base * > &infos)
Definition: info_cache.cpp:480
void x_RemoveFromGCQueue(CInfo_Base &info)
Definition: info_cache.cpp:424
size_t GetMaxGCQueueSize(void) const
Definition: info_cache.hpp:438
TGCQueue m_GCQueue
Definition: info_cache.hpp:505
size_t m_MinGCQueueSize
Definition: info_cache.hpp:504
void x_SetUsed(CInfo_Base &info)
Definition: info_cache.cpp:453
CInfoCache_Base(CInfoManager::TMainMutex &mutex)
Definition: info_cache.cpp:374
void x_SetUnused(CInfo_Base &info)
Definition: info_cache.cpp:463
CInfoManager::TMainMutex TMainMutex
Definition: info_cache.hpp:450
TCacheMutex m_CacheMutex
Definition: info_cache.hpp:456
bool x_Check(const vector< const CInfo_Base * > &infos) const
Definition: info_cache.cpp:396
void x_AcquireLoadLock(TCacheMutex::TWriteLockGuard &guard, CInfoRequestorLock &lock, EDoNotWait do_not_wait)
Definition: info_cache.hpp:473
void x_AddToGCQueue(CInfo_Base &info)
Definition: info_cache.cpp:435
size_t m_CurGCQueueSize
Definition: info_cache.hpp:504
void SetMaxGCQueueSize(size_t max_size)
Definition: info_cache.cpp:412
void x_AcquireLoadLock(TMainMutex::TWriteLockGuard &guard, CInfoLock_Base &lock, EDoNotWait do_not_wait)
Definition: info_cache.hpp:481
virtual void x_ForgetInfo(CInfo_Base &info)=0
void x_GC(void)
Definition: info_cache.cpp:489
virtual ~CInfoCache_Base(void)
Definition: info_cache.cpp:391
size_t m_MaxGCQueueSize
Definition: info_cache.hpp:504
CInfo_Base::TGCQueue TGCQueue
Definition: info_cache.hpp:502
CInfoLock< DataType > TInfoLock
Definition: info_cache.hpp:612
CInfo_Base::TExpirationTime TExpirationTime
Definition: info_cache.hpp:575
CInfoCache(CInfoManager::TMainMutex &mutex)
Definition: info_cache.hpp:577
CInfoCache(CInfoManager::TMainMutex &mutex, size_t max_size)
Definition: info_cache.hpp:581
KeyType key_type
Definition: info_cache.hpp:573
TInfoLock GetLoadLock(CInfoRequestor &requestor, const key_type &key, EDoNotWait do_not_wait=eAllowWaiting)
Definition: info_cache.hpp:627
bool MarkLoading(CInfoRequestor &requestor, const key_type &key)
Definition: info_cache.hpp:622
bool SetLoaded(CInfoRequestor &requestor, const key_type &key, const data_type &value, EExpirationType type)
Definition: info_cache.hpp:644
bool IsLoaded(CInfoRequestor &requestor, const key_type &key)
Definition: info_cache.hpp:614
bool x_Check(void) const
Definition: info_cache.hpp:697
virtual void x_ForgetInfo(CInfo_Base &info_base)
Definition: info_cache.hpp:708
~CInfoCache(void)
Definition: info_cache.hpp:585
map< key_type, CRef< TInfo > > TIndex
Definition: info_cache.hpp:715
bool SetLoadedFor(CInfoRequestor &requestor, const key_type &key, const data_type &value, TExpirationTime expiration_time)
Definition: info_cache.hpp:661
DataType data_type
Definition: info_cache.hpp:574
TInfoLock GetLoaded(CInfoRequestor &requestor, const key_type &key)
Definition: info_cache.hpp:678
TIndex m_Index
Definition: info_cache.hpp:717
TExpirationTime GetNewExpirationTime(EExpirationType type) const
Definition: info_cache.hpp:368
bool SetLoaded(EExpirationType type)
Definition: info_cache.hpp:360
bool IsLoaded(void) const
Definition: info_cache.hpp:352
TExpirationTime GetExpirationTime(void) const
Definition: info_cache.hpp:364
CInfoRequestor & GetRequestor(void) const
Definition: info_cache.hpp:373
bool x_SetLoadedFor(TDataMutex::TWriteLockGuard &, TExpirationTime expiration_time)
Definition: info_cache.hpp:407
SSystemMutex & GetDataLock(void) const
Definition: info_cache.hpp:403
bool x_SetLoaded(TDataMutex::TWriteLockGuard &, EExpirationType type)
Definition: info_cache.hpp:412
bool IsLocked(void) const
Definition: info_cache.hpp:347
DECLARE_OPERATOR_BOOL_REF(m_Lock)
CInfo_Base & GetInfo(void) const
Definition: info_cache.hpp:419
DECLARE_CLASS_STATIC_MUTEX(sm_DataMutex)
bool SetLoadedFor(TExpirationTime expiration_time)
Definition: info_cache.hpp:356
CRef< CInfoRequestorLock > m_Lock
Definition: info_cache.hpp:424
CInfo_Base::TExpirationTime TExpirationTime
Definition: info_cache.hpp:345
TInfo & GetInfo(void) const
Definition: info_cache.hpp:561
DataType TData
Definition: info_cache.hpp:534
CInfo_DataBase< DataType > TInfo
Definition: info_cache.hpp:533
bool SetLoadedFor(const TData &data, TExpirationTime expiration_time)
Definition: info_cache.hpp:550
TData GetData(void) const
Definition: info_cache.hpp:536
bool SetLoaded(const TData &data, EExpirationType type)
Definition: info_cache.hpp:541
void x_LockInfoMutex(CInfoRequestorLock &lock)
Definition: info_cache.cpp:131
bool x_DeadLock(const CInfoRequestor &requestor, const CInfo_Base &info) const
Definition: info_cache.cpp:302
CInfoManager(void)
Definition: info_cache.cpp:121
CFastMutex m_DeadlockMutex
Definition: info_cache.hpp:234
void x_AcquireLoadLock(TMainMutex::TWriteLockGuard &guard, CInfoRequestorLock &lock, EDoNotWait do_not_wait)
Definition: info_cache.cpp:214
void x_UnlockInfoMutex(CInfoRequestorLock &lock)
Definition: info_cache.cpp:146
vector< CRef< CLoadMutex > > TLoadMutexPool
Definition: info_cache.hpp:231
void ReleaseLoadLock(CInfoRequestorLock &lock)
Definition: info_cache.cpp:343
TMainMutex & GetMainMutex(void)
Definition: info_cache.hpp:197
TLoadMutexPool m_LoadMutexPool
Definition: info_cache.hpp:235
virtual ~CInfoManager(void)
Definition: info_cache.cpp:126
void x_ReleaseLoadLock(CInfoRequestorLock &lock)
Definition: info_cache.cpp:325
CMutex TMainMutex
Definition: info_cache.hpp:196
bool x_WaitForOtherLoader(TMainMutex::TWriteLockGuard &guard, CInfoRequestorLock &lock)
Definition: info_cache.cpp:257
TMainMutex m_MainMutex
Definition: info_cache.hpp:233
void ReleaseAllLoadLocks(CInfoRequestor &requestor)
Definition: info_cache.cpp:334
void x_ReleaseLoadMutex(CRef< CLoadMutex > &mutex)
Definition: info_cache.cpp:176
void x_AssignLoadMutex(CRef< CLoadMutex > &mutex)
Definition: info_cache.cpp:160
CInfoManager & GetManager(void) const
Definition: info_cache.hpp:336
bool SetLoadedFor(TExpirationTime new_expiration_time)
Definition: info_cache.cpp:79
CRef< CLoadMutex > m_Mutex
Definition: info_cache.hpp:186
CInfoRequestor & GetRequestor(void) const
Definition: info_cache.hpp:158
CInfo_Base::TExpirationTime TExpirationTime
Definition: info_cache.hpp:151
bool SetLoaded(EExpirationType type)
Definition: info_cache.hpp:321
bool x_SetLoaded(TMainMutex::TWriteLockGuard &guard, EExpirationType type)
Definition: info_cache.hpp:328
CInfoRequestor & m_Requestor
Definition: info_cache.hpp:184
CInfoRequestorLock(CInfoRequestor &requestor, CInfo_Base &info)
Definition: info_cache.cpp:66
TExpirationTime GetNewExpirationTime(EExpirationType type) const
Definition: info_cache.hpp:314
CInfo_Base & GetInfo(void) const
Definition: info_cache.hpp:153
CRef< CInfo_Base > m_Info
Definition: info_cache.hpp:185
bool IsLoaded(void) const
Definition: info_cache.hpp:306
bool IsLocked(void) const
Definition: info_cache.hpp:165
bool x_SetLoadedFor(TMainMutex::TWriteLockGuard &guard, TExpirationTime new_expiration_time)
Definition: info_cache.cpp:92
TExpirationTime GetExpirationTime(void) const
Definition: info_cache.hpp:173
CInfoRequestor(CInfoManager &manager)
Definition: info_cache.cpp:510
virtual TExpirationTime GetRequestTime(void) const =0
CInfo_Base::TExpirationTime TExpirationTime
Definition: info_cache.hpp:250
unordered_map< CInfoCache_Base *, vector< CInfo_Base * >, PtrHash > TCacheMap
Definition: info_cache.hpp:280
void ReleaseAllLoadLocks(void)
Definition: info_cache.hpp:245
void ReleaseAllUsedInfos(void)
Definition: info_cache.cpp:536
unordered_map< CInfo_Base *, CRef< CInfoRequestorLock >, PtrHash > TLockMap
Definition: info_cache.hpp:279
void ReleaseLoadLock(CInfoRequestorLock &lock)
Definition: info_cache.hpp:266
TLockMap m_LockMap
Definition: info_cache.hpp:283
CRef< CInfoManager > m_Manager
Definition: info_cache.hpp:282
CRef< CInfo_Base > m_WaitingForInfo
Definition: info_cache.hpp:287
TCacheMap m_CacheMap
Definition: info_cache.hpp:284
virtual TExpirationTime GetNewExpirationTime(EExpirationType type) const =0
virtual ~CInfoRequestor(void)
Definition: info_cache.cpp:516
CInfoManager & GetManager(void) const
Definition: info_cache.hpp:259
CRef< CInfoRequestorLock > x_GetLock(CInfoCache_Base &cache, CInfo_Base &info)
Definition: info_cache.cpp:523
TUseCounter m_UseCounter
Definition: info_cache.hpp:129
CInfo_Base(TGCQueue &gc_queue)
Definition: info_cache.cpp:48
bool IsLoaded(TExpirationTime expiration_time) const
Definition: info_cache.hpp:292
list< CRef< CInfo_Base > > TGCQueue
Definition: info_cache.hpp:110
atomic< TExpirationTime > m_ExpirationTime
Definition: info_cache.hpp:131
CRef< CLoadMutex > m_LoadMutex
Definition: info_cache.hpp:132
TGCQueue::iterator m_GCQueuePos
Definition: info_cache.hpp:133
Uint4 TExpirationTime
Definition: info_cache.hpp:108
virtual ~CInfo_Base(void)
Definition: info_cache.cpp:56
TExpirationTime GetExpirationTime(void) const
Definition: info_cache.hpp:117
CInfo_DataBase(typename CInfo_Base::TGCQueue &gc_queue)
Definition: info_cache.hpp:520
DataType TData
Definition: info_cache.hpp:515
bool IsLoading(void) const
Definition: info_cache.hpp:91
atomic< CInfoRequestor * > m_LoadingRequestor
Definition: info_cache.hpp:101
CLoadMutex(void)
Definition: info_cache.hpp:86
CMutex –.
Definition: ncbimtx.hpp:749
CObject –.
Definition: ncbiobj.hpp:180
INoCopying(const INoCopying &)=delete
void operator=(const INoCopying &)=delete
void erase(iterator pos)
Definition: map.hpp:167
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Include a standard set of the NCBI C++ Toolkit most basic headers.
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define _VERIFY(expr)
Definition: ncbidbg.hpp:161
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
Definition: ncbiobj.hpp:744
TObjectType & GetNCObject(void) const
Get object.
Definition: ncbiobj.hpp:1187
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
CMutexGuard TWriteLockGuard
Define Write Lock Guard.
Definition: ncbimtx.hpp:763
EDoNotWait
Definition: info_cache.hpp:73
@ eDoNotWait
Definition: info_cache.hpp:75
@ eAllowWaiting
Definition: info_cache.hpp:74
EExpirationType
Definition: info_cache.hpp:78
@ eExpire_fast
Definition: info_cache.hpp:80
@ eExpire_normal
Definition: info_cache.hpp:79
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Multi-threading – mutexes; rw-locks; semaphore.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines: CTimeFormat - storage class for time format.
size_t operator()(const void *ptr) const
Definition: info_cache.hpp:275
Definition: type.c:6
#define _ASSERT
Modified on Wed May 29 18:42:52 2024 by modify_doxy.py rev. 669887