diff options
author | Mike Buland <eichlan@xagasoft.com> | 2013-07-20 15:17:39 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2013-07-20 15:17:39 +0000 |
commit | e97cac3fbab4a00faeb3ddec08846307670b9a0e (patch) | |
tree | 2a376981cb234c7278a463edc595363980b9bd4a | |
parent | 51eef132bb2bb67e658756eaebeae5e52c13de98 (diff) | |
download | libbu++-e97cac3fbab4a00faeb3ddec08846307670b9a0e.tar.gz libbu++-e97cac3fbab4a00faeb3ddec08846307670b9a0e.tar.bz2 libbu++-e97cac3fbab4a00faeb3ddec08846307670b9a0e.tar.xz libbu++-e97cac3fbab4a00faeb3ddec08846307670b9a0e.zip |
Added a Locker class to the Bu::CacheObject base class. This is a super simple
wrapper that lets you take advantage of nifty Locker based mutex locking when
in a CacheObject subclass.
Diffstat (limited to '')
-rw-r--r-- | src/unstable/cacheobject.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/unstable/cacheobject.h b/src/unstable/cacheobject.h index 4606493..e83f706 100644 --- a/src/unstable/cacheobject.h +++ b/src/unstable/cacheobject.h | |||
@@ -33,6 +33,7 @@ namespace Bu | |||
33 | { | 33 | { |
34 | } | 34 | } |
35 | 35 | ||
36 | typedef CacheObject<keytype, obtype> MyType; | ||
36 | typedef CacheBase<keytype, obtype> CacheType; | 37 | typedef CacheBase<keytype, obtype> CacheType; |
37 | 38 | ||
38 | virtual keytype getKey() const=0; | 39 | virtual keytype getKey() const=0; |
@@ -62,6 +63,24 @@ namespace Bu | |||
62 | return bChanged; | 63 | return bChanged; |
63 | } | 64 | } |
64 | 65 | ||
66 | class Locker | ||
67 | { | ||
68 | public: | ||
69 | Locker( const MyType *pObj ) : | ||
70 | pObj( pObj ) | ||
71 | { | ||
72 | pObj->lock(); | ||
73 | } | ||
74 | |||
75 | ~Locker() | ||
76 | { | ||
77 | pObj->unlock(); | ||
78 | } | ||
79 | |||
80 | private: | ||
81 | const MyType *pObj; | ||
82 | }; | ||
83 | |||
65 | protected: | 84 | protected: |
66 | void changed( bool bChanged=true ) | 85 | void changed( bool bChanged=true ) |
67 | { | 86 | { |