summaryrefslogtreecommitdiff
path: root/src/unstable/cacheobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/unstable/cacheobject.h')
-rw-r--r--src/unstable/cacheobject.h20
1 files changed, 19 insertions, 1 deletions
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: