aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2013-07-18 02:09:29 +0000
committerMike Buland <eichlan@xagasoft.com>2013-07-18 02:09:29 +0000
commit51eef132bb2bb67e658756eaebeae5e52c13de98 (patch)
treef99d9e36ab2b3bbcb26d106cd0a71a03f27a8eb5 /src
parent65cc54be0a14e627938731ff8deefea61c2c1cfa (diff)
downloadlibbu++-51eef132bb2bb67e658756eaebeae5e52c13de98.tar.gz
libbu++-51eef132bb2bb67e658756eaebeae5e52c13de98.tar.bz2
libbu++-51eef132bb2bb67e658756eaebeae5e52c13de98.tar.xz
libbu++-51eef132bb2bb67e658756eaebeae5e52c13de98.zip
Fixed caching changed issue. The cache now marks objects as unchanged for you
after they are saved. It needs some more testing, but the theory is sound.
Diffstat (limited to 'src')
-rw-r--r--src/tests/cache.cpp5
-rw-r--r--src/unstable/cachebase.h7
-rw-r--r--src/unstable/uuid.cpp1
3 files changed, 9 insertions, 4 deletions
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp
index 20b384e..7982b2d 100644
--- a/src/tests/cache.cpp
+++ b/src/tests/cache.cpp
@@ -171,6 +171,8 @@ namespace Bu
171 default: 171 default:
172 throw Bu::ExceptionBase("Flagrant error! Invalid type!"); 172 throw Bu::ExceptionBase("Flagrant error! Invalid type!");
173 } 173 }
174
175 return NULL;
174 } 176 }
175} 177}
176 178
@@ -179,7 +181,7 @@ typedef Bu::CachePtr<Bu::Uuid, SubSomethingA, Something> SomethingAPtr;
179typedef Bu::CachePtr<Bu::Uuid, SubSomethingB, Something> SomethingBPtr; 181typedef Bu::CachePtr<Bu::Uuid, SubSomethingB, Something> SomethingBPtr;
180typedef Bu::MyriadCache<Bu::Uuid, Something> SomethingCache; 182typedef Bu::MyriadCache<Bu::Uuid, Something> SomethingCache;
181 183
182int main( int argc, char *argv[] ) 184int main( int, char *[] )
183{ 185{
184 Bu::File fStore("test.myr", Bu::File::Create|Bu::File::ReadWrite); 186 Bu::File fStore("test.myr", Bu::File::Create|Bu::File::ReadWrite);
185 SomethingCache c( fStore ); 187 SomethingCache c( fStore );
@@ -196,7 +198,6 @@ int main( int argc, char *argv[] )
196 198
197 SomethingCache::KeyList lKeys = c.getKeys(); 199 SomethingCache::KeyList lKeys = c.getKeys();
198 Bu::println("Count: %1").arg( lKeys.getSize() ); 200 Bu::println("Count: %1").arg( lKeys.getSize() );
199 int j = 0;
200 for( SomethingCache::KeyList::iterator i = lKeys.begin(); i; i++ ) 201 for( SomethingCache::KeyList::iterator i = lKeys.begin(); i; i++ )
201 { 202 {
202 Bu::println(" - %1: '%2'").arg( *i ).arg( c.get( *i )->toString() ); 203 Bu::println(" - %1: '%2'").arg( *i ).arg( c.get( *i )->toString() );
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h
index 6cc3e77..af2884c 100644
--- a/src/unstable/cachebase.h
+++ b/src/unstable/cachebase.h
@@ -184,7 +184,8 @@ namespace Bu
184 pEnt( rhs.pEnt ), 184 pEnt( rhs.pEnt ),
185 pData( rhs.pData ) 185 pData( rhs.pData )
186 { 186 {
187 pEnt->incRef(); 187 if( pEnt )
188 pEnt->incRef();
188 } 189 }
189 190
190 virtual ~CachePtr() 191 virtual ~CachePtr()
@@ -228,7 +229,8 @@ namespace Bu
228 kId = rhs.kId; 229 kId = rhs.kId;
229 pEnt = rhs.pEnt; 230 pEnt = rhs.pEnt;
230 pData = rhs.pData; 231 pData = rhs.pData;
231 pEnt->incRef(); 232 if( pEnt )
233 pEnt->incRef();
232 234
233 return *this; 235 return *this;
234 } 236 }
@@ -513,6 +515,7 @@ namespace Bu
513 Entry *pEnt = hCacheEntry.get( i.getKey() ); 515 Entry *pEnt = hCacheEntry.get( i.getKey() );
514 Bu::MutexLocker ml( pEnt->getMutex() ); 516 Bu::MutexLocker ml( pEnt->getMutex() );
515 _save( pEnt->getPtr() ); 517 _save( pEnt->getPtr() );
518 pEnt->getPtr()->changed( false );
516 } 519 }
517 hChanged.clear(); 520 hChanged.clear();
518 } 521 }
diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp
index a93f713..304ea4a 100644
--- a/src/unstable/uuid.cpp
+++ b/src/unstable/uuid.cpp
@@ -77,6 +77,7 @@ int Bu::Uuid::getVersion()
77 77
78void Bu::Uuid::clear() 78void Bu::Uuid::clear()
79{ 79{
80 memset( data, 0, 16 );
80 data[7] = msb(0); 81 data[7] = msb(0);
81} 82}
82 83