summaryrefslogtreecommitdiff
path: root/db/db_test.cc
diff options
context:
space:
mode:
authorcostan <costan@google.com>2018-03-23 12:50:14 -0700
committerVictor Costan <pwnall@chromium.org>2018-03-23 12:56:14 -0700
commit0db30413a4cfa8c980e675ba5cb96717d688af92 (patch)
tree6194fe595f5bac1f71216bf659cb95f4e78cd773 /db/db_test.cc
parent04f39105c5a418905da8b7657ca244d672c99d3b (diff)
downloadleveldb-0db30413a4cfa8c980e675ba5cb96717d688af92.tar.gz
leveldb: Add more thread safety annotations.
After this CL, all classes with Mutex members should be covered by annotations. Exceptions are atomic members, which shouldn't need locking, and DBImpl members that cause errors when annotated, which will be tackled separately. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190260865
Diffstat (limited to 'db/db_test.cc')
-rw-r--r--db/db_test.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/db/db_test.cc b/db/db_test.cc
index c818113..b1d2cd8 100644
--- a/db/db_test.cc
+++ b/db/db_test.cc
@@ -11,6 +11,8 @@
#include "leveldb/cache.h"
#include "leveldb/env.h"
#include "leveldb/table.h"
+#include "port/port.h"
+#include "port/thread_annotations.h"
#include "util/hash.h"
#include "util/logging.h"
#include "util/mutexlock.h"
@@ -36,21 +38,21 @@ namespace {
class AtomicCounter {
private:
port::Mutex mu_;
- int count_;
+ int count_ GUARDED_BY(mu_);
public:
AtomicCounter() : count_(0) { }
void Increment() {
IncrementBy(1);
}
- void IncrementBy(int count) {
+ void IncrementBy(int count) LOCKS_EXCLUDED(mu_) {
MutexLock l(&mu_);
count_ += count;
}
- int Read() {
+ int Read() LOCKS_EXCLUDED(mu_) {
MutexLock l(&mu_);
return count_;
}
- void Reset() {
+ void Reset() LOCKS_EXCLUDED(mu_) {
MutexLock l(&mu_);
count_ = 0;
}