mirror of
https://github.com/google/leveldb.git
synced 2024-12-13 21:48:58 +08:00
946e5b5a4c
Highlights ---------- Mmap at most 1000 files on Posix to improve performance for large databases. Support for more architectures (thanks to Alexander K.) Building and porting -------------------- HP/UX support (issue 126) AtomicPointer for ia64 (issue 123) Sparc v9 support (issue 124) Atomic ops for powerpc Use -fno-builtin-memcmp only when using g++ Simplify IOS build rules (issue 114) Use CXXFLAGS instead of CFLAGS when invoking C++ compiler (issue 118) Fix snappy shared library problem (issue 94) Fix shared library installation path regression Endian-ness detection tweak for FreeBSD Bug fixes --------- Stop ignoring FLAGS_open_files in db_bench Make bloom test behavior agnostic to endian-ness Performance ----------- Limit number of mmapped files to 1000 to improve perf for large dbs Do not delay for 1 second on shutdown path (issue 125) Misc ---- Make InMemoryEnv return a no-op logger C binding now has a wrapper for free (issue 117) Add thread-safety annotations Added an in-process lock table (issue 120) Make RandomAccessFile and SequentialFile non-copyable
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#ifndef STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
|
|
#define STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
|
|
|
|
#include "port/port.h"
|
|
#include "port/thread_annotations.h"
|
|
|
|
namespace leveldb {
|
|
|
|
// Helper class that locks a mutex on construction and unlocks the mutex when
|
|
// the destructor of the MutexLock object is invoked.
|
|
//
|
|
// Typical usage:
|
|
//
|
|
// void MyClass::MyMethod() {
|
|
// MutexLock l(&mu_); // mu_ is an instance variable
|
|
// ... some complex code, possibly with multiple return paths ...
|
|
// }
|
|
|
|
class SCOPED_LOCKABLE MutexLock {
|
|
public:
|
|
explicit MutexLock(port::Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu)
|
|
: mu_(mu) {
|
|
this->mu_->Lock();
|
|
}
|
|
~MutexLock() UNLOCK_FUNCTION() { this->mu_->Unlock(); }
|
|
|
|
private:
|
|
port::Mutex *const mu_;
|
|
// No copying allowed
|
|
MutexLock(const MutexLock&);
|
|
void operator=(const MutexLock&);
|
|
};
|
|
|
|
} // namespace leveldb
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
|