From a66f643e97d7926ea3365d883bac4dc91f54a909 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Fri, 15 May 2015 15:55:20 -0700 Subject: [PATCH] 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 --- include/rocksdb/thread_status.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/rocksdb/thread_status.h b/include/rocksdb/thread_status.h index e695b48db..e642284d4 100644 --- a/include/rocksdb/thread_status.h +++ b/include/rocksdb/thread_status.h @@ -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.