2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2015-02-17 19:29:36 +00: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 02:02:00 +00:00
|
|
|
#include "monitoring/thread_status_updater.h"
|
|
|
|
#include "monitoring/thread_status_util.h"
|
2015-02-17 19:29:36 +00: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-13 22:58:45 +00: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 19:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !NDEBUG
|
|
|
|
|
|
|
|
} // namespace rocksdb
|