2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2015-02-17 20:29:36 +01:00
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "monitoring/thread_status_updater.h"
|
|
|
|
#include "monitoring/thread_status_util.h"
|
2015-02-17 20:29:36 +01:00
|
|
|
#include "rocksdb/env.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
// the delay for debugging purpose.
|
|
|
|
static std::atomic<int> states_delay[ThreadStatus::NUM_STATE_TYPES];
|
|
|
|
|
|
|
|
void ThreadStatusUtil::TEST_SetStateDelay(
|
|
|
|
const ThreadStatus::StateType state, int micro) {
|
|
|
|
states_delay[state].store(micro, std::memory_order_relaxed);
|
|
|
|
}
|
|
|
|
|
2015-04-14 00:58:45 +02:00
|
|
|
void ThreadStatusUtil::TEST_StateDelay(const ThreadStatus::StateType state) {
|
|
|
|
auto delay = states_delay[state].load(std::memory_order_relaxed);
|
|
|
|
if (delay > 0) {
|
|
|
|
Env::Default()->SleepForMicroseconds(delay);
|
|
|
|
}
|
2015-02-17 20:29:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !NDEBUG
|
|
|
|
|
|
|
|
} // namespace rocksdb
|