summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-10-30 18:10:41 -0700
committerJamie Gennis <jgennis@google.com>2011-10-31 18:48:31 -0700
commit94c1f148bb655a3dd3c2a2167476239b41305ff0 (patch)
tree0a7bf345bb97a55b7cdcfa2c29d1493734027e92
parent62015f5d0d1104dfc682b3eb3b6c0be4f63b985a (diff)
downloadframeworks_base-94c1f148bb655a3dd3c2a2167476239b41305ff0.zip
frameworks_base-94c1f148bb655a3dd3c2a2167476239b41305ff0.tar.gz
frameworks_base-94c1f148bb655a3dd3c2a2167476239b41305ff0.tar.bz2
BlobCache: remove the mutex locking
This change removes the mutex from the BlobCache class. The caller must be responsible for thread synchronization in order to properly implement the Flattenable interface, which is coming soon. Otherwise would be the potential for the cache contents to change between the call to the getFlattenedSize and flatten methods. Because the caller must do this synchronization anyway there's no reason to also some synchronization inside BlobCache. Change-Id: Ie1f4f6f82b78744f46a41ce863cac0cad276a20e
-rw-r--r--include/utils/BlobCache.h11
-rw-r--r--libs/utils/BlobCache.cpp2
2 files changed, 3 insertions, 10 deletions
diff --git a/include/utils/BlobCache.h b/include/utils/BlobCache.h
index dc45ff0..11d4246 100644
--- a/include/utils/BlobCache.h
+++ b/include/utils/BlobCache.h
@@ -25,8 +25,8 @@
namespace android {
-// A BlobCache is an in-memory cache for binary key/value pairs. All the public
-// methods are thread-safe.
+// A BlobCache is an in-memory cache for binary key/value pairs. A BlobCache
+// does NOT provide any thread-safety guarantees.
//
// The cache contents can be serialized to a file and reloaded in a subsequent
// execution of the program. This serialization is non-portable and should only
@@ -166,17 +166,12 @@ private:
size_t mTotalSize;
// mRandState is the pseudo-random number generator state. It is passed to
- // nrand48 to generate random numbers when needed. It must be protected by
- // mMutex.
+ // nrand48 to generate random numbers when needed.
unsigned short mRandState[3];
// mCacheEntries stores all the cache entries that are resident in memory.
// Cache entries are added to it by the 'set' method.
SortedVector<CacheEntry> mCacheEntries;
-
- // mMutex is used to synchronize access to all member variables. It must be
- // locked any time the member variables are written or read.
- Mutex mMutex;
};
}
diff --git a/libs/utils/BlobCache.cpp b/libs/utils/BlobCache.cpp
index 590576a..15155b2 100644
--- a/libs/utils/BlobCache.cpp
+++ b/libs/utils/BlobCache.cpp
@@ -67,7 +67,6 @@ void BlobCache::set(const void* key, size_t keySize, const void* value,
return;
}
- Mutex::Autolock lock(mMutex);
sp<Blob> dummyKey(new Blob(key, keySize, false));
CacheEntry dummyEntry(dummyKey, NULL);
@@ -129,7 +128,6 @@ size_t BlobCache::get(const void* key, size_t keySize, void* value,
keySize, mMaxKeySize);
return 0;
}
- Mutex::Autolock lock(mMutex);
sp<Blob> dummyKey(new Blob(key, keySize, false));
CacheEntry dummyEntry(dummyKey, NULL);
ssize_t index = mCacheEntries.indexOf(dummyEntry);