aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/cacheobject.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2015-08-25 21:47:49 +0000
committerMike Buland <eichlan@xagasoft.com>2015-08-25 21:47:49 +0000
commit6d5135aa23f2ae12d953ceab1c1d01e003a55be1 (patch)
tree75ad30019a6780bb76e8adc0c744b4a747193f40 /src/unstable/cacheobject.h
parent04f68d35183bb98c04f09b077e650cf90ff72139 (diff)
downloadlibbu++-6d5135aa23f2ae12d953ceab1c1d01e003a55be1.tar.gz
libbu++-6d5135aa23f2ae12d953ceab1c1d01e003a55be1.tar.bz2
libbu++-6d5135aa23f2ae12d953ceab1c1d01e003a55be1.tar.xz
libbu++-6d5135aa23f2ae12d953ceab1c1d01e003a55be1.zip
Added more lock/unlock features to the cache Lockers. That...was a weird
sentence, but it's true. Also, oddly enough, Lockers aren't thread-safe, but they shouldn't ever have to be. Figure that one out!
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: