aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unstable/cachebase.h8
-rw-r--r--src/unstable/cacheobject.h20
2 files changed, 27 insertions, 1 deletions
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h
index d5b4382..2e0f24f 100644
--- a/src/unstable/cachebase.h
+++ b/src/unstable/cachebase.h
@@ -351,6 +351,14 @@ namespace Bu
351 bLocked = false; 351 bLocked = false;
352 } 352 }
353 353
354 void lock()
355 {
356 if( bLocked )
357 return;
358 rPtr.lock();
359 bLocked = true;
360 }
361
354 private: 362 private:
355 MyType &rPtr; 363 MyType &rPtr;
356 bool bLocked; 364 bool bLocked;
diff --git a/src/unstable/cacheobject.h b/src/unstable/cacheobject.h
index e519a9c..080312f 100644
--- a/src/unstable/cacheobject.h
+++ b/src/unstable/cacheobject.h
@@ -69,18 +69,36 @@ namespace Bu
69 { 69 {
70 public: 70 public:
71 Locker( const MyType *pObj ) : 71 Locker( const MyType *pObj ) :
72 pObj( pObj ) 72 pObj( pObj ),
73 bLocked( true )
73 { 74 {
74 pObj->lock(); 75 pObj->lock();
75 } 76 }
76 77
77 ~Locker() 78 ~Locker()
78 { 79 {
80 unlock();
81 }
82
83 void unlock()
84 {
85 if( !bLocked )
86 return;
79 pObj->unlock(); 87 pObj->unlock();
88 bLocked = false;
89 }
90
91 void lock()
92 {
93 if( bLocked )
94 return;
95 pObj->lock();
96 bLocked = true;
80 } 97 }
81 98
82 private: 99 private:
83 const MyType *pObj; 100 const MyType *pObj;
101 bool bLocked;
84 }; 102 };
85 103
86 protected: 104 protected: