From 55f8e2c01fe4513d5e3de55f567c392b4a18ecc2 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 13 Mar 2013 05:03:59 +0000 Subject: Added bind/unbind to the Cache system. Fixed typo in docs of heap. --- src/tests/cache.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/tests/cache.cpp') diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index 15662af..aa71c39 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp @@ -220,7 +220,7 @@ public: virtual ~CachePtr() { - release(); + unbind(); } const keytype &getKey() const @@ -230,31 +230,31 @@ public: obtype &operator*() { - checkRef(); + bind(); return pData; } const obtype &operator*() const { - checkRef(); + bind(); return pData; } obtype *operator->() { - checkRef(); + bind(); return pData; } const obtype *operator->() const { - checkRef(); + bind(); return pData; } MyType operator=( const MyType &rhs ) { - release(); + unbind(); pCache = rhs.pCache; kId = rhs.kId; pEnt = rhs.pEnt; @@ -275,22 +275,27 @@ public: return pCache != rhs.pCache || kId != rhs.kId; } + + void bind() + { + CachePtrInterface::checkRef( pCache, kId, pEnt, pData ); + } - void release() + void unbind() { CachePtrInterface::releaseRef( pCache, pEnt, pData ); } void lock() { - checkRef(); + bind(); if( pEnt ) pEnt->lock(); } void unlock() { - checkRef(); + bind(); if( pEnt ) pEnt->unlock(); } @@ -323,12 +328,6 @@ public: bool bLocked; }; -private: - void checkRef() - { - CachePtrInterface::checkRef( pCache, kId, pEnt, pData ); - } - private: CacheBase *pCache; mutable keytype kId; @@ -658,13 +657,13 @@ int main( int argc, char *argv[] ) c._debug(); - p1.release(); + p1.unbind(); c._debug(); Bu::println("Name: %1").arg( p1->getName() ); - p1.release(); + p1.unbind(); p1.lock(); p1.unlock(); -- cgit v1.2.3