Use a better way to initialize ThreadStatus::kNumOperationProperties.

Summary: Use a better way to initialize ThreadStatus::kNumOperationProperties.

Test Plan: make

Reviewers: sdong, rven, anthony, krishnanm86, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D38547
This commit is contained in:
Yueh-Hsuan Chiang 2015-05-15 15:55:20 -07:00
parent 7413306d94
commit a66f643e97

View File

@ -29,6 +29,12 @@
namespace rocksdb {
// TODO(yhchiang): remove this function once c++14 is available
// as std::max will be able to cover this.
constexpr int constexpr_max(int a, int b) {
return a > b ? a : b;
}
// A structure that describes the current status of a thread.
// The status of active threads can be fetched using
// rocksdb::GetThreadList().
@ -67,10 +73,6 @@ struct ThreadStatus {
NUM_OP_STAGES
};
// The maximum number of properties of an operation.
// This number should be set to the biggest NUM_XXX_PROPERTIES.
static const int kNumOperationProperties = 6;
enum CompactionPropertyType : int {
COMPACTION_JOB_ID = 0,
COMPACTION_INPUT_OUTPUT_LEVEL,
@ -89,6 +91,11 @@ struct ThreadStatus {
NUM_FLUSH_PROPERTIES
};
// The maximum number of properties of an operation.
// This number should be set to the biggest NUM_XXX_PROPERTIES.
static const int kNumOperationProperties = constexpr_max(
NUM_COMPACTION_PROPERTIES, NUM_FLUSH_PROPERTIES);
// The type used to refer to a thread state.
// A state describes lower-level action of a thread
// such as reading / writing a file or waiting for a mutex.