mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-28 05:43:50 +00:00
42d6652ba2
Summary: The files in `port/`, such as `port_posix.h`, are layering over the system libraries, so shouldn't include the DB-specific files like `options.h`. This PR remove this dependency. # How The reason that `port_posix.h` (or `port_win.h`) include `options.h` is to use `CpuPriority`, as there is a method `SetCpuPriority()` in `port_posix.h` that uses `CpuPriority.` - I think `SetCpuPriority()` make sense to exist in `port_posix.h` as it provides has platform-dependent implementation - `CpuPriority` enum is defined in `env.h`, but used in `rocksdb/include` and `port/`. Hence, let us define `CpuPriority` enum in a common file, say `port_defs.h`, such that both directories `rocksdb/include` and `port/` can include. When we remove this dependency, some other files have compile errors because they can't find definitions, so add header files to resolve # Test make all check -j Pull Request resolved: https://github.com/facebook/rocksdb/pull/11214 Reviewed By: pdillinger Differential Revision: D43196910 Pulled By: guowentian fbshipit-source-id: 70deccb72844cfb08fcc994f76c6ef6df5d55ab9
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
// This file declares a wrapper around the efficient folly DistributedMutex
|
|
// that falls back on a standard mutex when not available. See
|
|
// https://github.com/facebook/folly/blob/main/folly/synchronization/DistributedMutex.h
|
|
// for benefits and limitations.
|
|
|
|
// At the moment, only scoped locking is supported using DMutexLock
|
|
// RAII wrapper, because lock/unlock APIs will vary.
|
|
|
|
#ifdef USE_FOLLY
|
|
|
|
#include <folly/synchronization/DistributedMutex.h>
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
class DMutex : public folly::DistributedMutex {
|
|
public:
|
|
static const char* kName() { return "folly::DistributedMutex"; }
|
|
|
|
explicit DMutex(bool IGNORED_adaptive = false) { (void)IGNORED_adaptive; }
|
|
|
|
// currently no-op
|
|
void AssertHeld() {}
|
|
};
|
|
using DMutexLock = std::lock_guard<folly::DistributedMutex>;
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
|
|
|
#else
|
|
|
|
#include <mutex>
|
|
|
|
#include "port/port.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
using DMutex = port::Mutex;
|
|
using DMutexLock = std::lock_guard<DMutex>;
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
|
|
|
#endif
|