]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/monitoring/instrumented_mutex.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
8 #include "monitoring/statistics.h"
10 #include "rocksdb/env.h"
11 #include "rocksdb/statistics.h"
12 #include "rocksdb/thread_status.h"
13 #include "util/stop_watch.h"
16 class InstrumentedCondVar
;
18 // A wrapper class for port::Mutex that provides additional layer
19 // for collecting stats and instrumentation.
20 class InstrumentedMutex
{
22 explicit InstrumentedMutex(bool adaptive
= false)
23 : mutex_(adaptive
), stats_(nullptr), env_(nullptr),
27 Statistics
* stats
, Env
* env
,
28 int stats_code
, bool adaptive
= false)
29 : mutex_(adaptive
), stats_(stats
), env_(env
),
30 stats_code_(stats_code
) {}
44 friend class InstrumentedCondVar
;
51 // A wrapper class for port::Mutex that provides additional layer
52 // for collecting stats and instrumentation.
53 class InstrumentedMutexLock
{
55 explicit InstrumentedMutexLock(InstrumentedMutex
* mutex
) : mutex_(mutex
) {
59 ~InstrumentedMutexLock() {
64 InstrumentedMutex
* const mutex_
;
65 InstrumentedMutexLock(const InstrumentedMutexLock
&) = delete;
66 void operator=(const InstrumentedMutexLock
&) = delete;
69 class InstrumentedCondVar
{
71 explicit InstrumentedCondVar(InstrumentedMutex
* instrumented_mutex
)
72 : cond_(&(instrumented_mutex
->mutex_
)),
73 stats_(instrumented_mutex
->stats_
),
74 env_(instrumented_mutex
->env_
),
75 stats_code_(instrumented_mutex
->stats_code_
) {}
79 bool TimedWait(uint64_t abs_time_us
);
91 bool TimedWaitInternal(uint64_t abs_time_us
);
98 } // namespace rocksdb