From 53ac1cc57ef8b7ea3af02ea6aa529fe8614ea784 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 13 May 2024 15:29:40 -0500 Subject: [PATCH] Starting to fix CodeQL security warnings --- .github/workflows/codeql.yml | 1 + .../coalescing/src/performance_counters.cpp | 465 +++++++++--------- .../parse_command_line_local.hpp | 6 +- libs/core/errors/include/hpx/errors/error.hpp | 4 +- .../src/utf8_codecvt_facet.cpp | 10 +- .../hpx/runtime_local/os_thread_type.hpp | 12 +- .../src/detail/background_thread.cpp | 5 +- .../threading_base/detail/switch_status.hpp | 4 +- .../threading_base/src/register_thread.cpp | 8 +- libs/full/init_runtime/src/hpx_init.cpp | 10 +- .../src/connection_handler_tcp.cpp | 1 + .../server/arithmetics_counter_extended.hpp | 4 +- .../src/server/action_invocation_counter.cpp | 67 ++- .../src/server/arithmetics_counter.cpp | 89 ++-- .../server/arithmetics_counter_extended.cpp | 97 ++-- .../src/server/component_instance_counter.cpp | 100 ++-- .../src/server/elapsed_time_counter.cpp | 42 +- .../src/server/statistics_counter.cpp | 112 ++--- 18 files changed, 491 insertions(+), 546 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5a2332a5822b..a6d188a4864f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -80,6 +80,7 @@ jobs: # filter out all files from downloaded dependencies patterns: | -**/_deps/** + -**/concurrentqueue.hpp input: sarif-results/cpp.sarif output: sarif-results/cpp.sarif diff --git a/components/parcel_plugins/coalescing/src/performance_counters.cpp b/components/parcel_plugins/coalescing/src/performance_counters.cpp index 722367e78075..0fbe53f50457 100644 --- a/components/parcel_plugins/coalescing/src/performance_counters.cpp +++ b/components/parcel_plugins/coalescing/src/performance_counters.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2022 Hartmut Kaiser +// Copyright (c) 2016-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -90,57 +90,53 @@ namespace hpx::plugins::parcel { hpx::performance_counters::counter_info const& info, hpx::error_code& ec) { - switch (info.type_) + if (info.type_ != + performance_counters::counter_type::monotonically_increasing) { - case performance_counters::counter_type::monotonically_increasing: - { - performance_counters::counter_path_elements paths; - performance_counters::get_counter_path_elements( - info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_parcels_counter_creator", - "invalid counter name for number of parcels (instance " - "name must not be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_parcels_counter_creator", - "invalid counter parameter for number of parcels: must " - "specify an action type"); - return naming::invalid_gid; - } - - // ask registry - hpx::function f = - coalescing_counter_registry::instance().get_parcels_counter( - paths.parameters_); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_parcels_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - if (!f.empty()) - { - return performance_counters::detail::create_raw_counter( - info, HPX_MOVE(f), ec); - } + performance_counters::counter_path_elements paths; + performance_counters::get_counter_path_elements( + info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - // the counter is not available yet, create surrogate function - return performance_counters::detail::create_raw_counter( - info, num_parcels_counter_surrogate(paths.parameters_), ec); + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_parcels_counter_creator", + "invalid counter name for number of parcels (instance " + "name must not be a valid base counter name)"); + return naming::invalid_gid; } - break; - default: + if (paths.parameters_.empty()) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "num_parcels_counter_creator", - "invalid counter type requested"); + "invalid counter parameter for number of parcels: must " + "specify an action type"); return naming::invalid_gid; } + + // ask registry + hpx::function f = + coalescing_counter_registry::instance().get_parcels_counter( + paths.parameters_); + + if (!f.empty()) + { + return performance_counters::detail::create_raw_counter( + info, HPX_MOVE(f), ec); + } + + // the counter is not available yet, create surrogate function + return performance_counters::detail::create_raw_counter( + info, num_parcels_counter_surrogate(paths.parameters_), ec); } /////////////////////////////////////////////////////////////////////////// @@ -173,57 +169,53 @@ namespace hpx::plugins::parcel { hpx::performance_counters::counter_info const& info, hpx::error_code& ec) { - switch (info.type_) + if (info.type_ != + performance_counters::counter_type::monotonically_increasing) { - case performance_counters::counter_type::monotonically_increasing: - { - performance_counters::counter_path_elements paths; - performance_counters::get_counter_path_elements( - info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_messages_counter_creator", - "invalid counter name for number of parcels (instance " - "name must not be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_messages_counter_creator", - "invalid counter parameter for number of parcels: must " - "specify an action type"); - return naming::invalid_gid; - } - - // ask registry - hpx::function f = - coalescing_counter_registry::instance().get_messages_counter( - paths.parameters_); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_messages_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - if (!f.empty()) - { - return performance_counters::detail::create_raw_counter( - info, HPX_MOVE(f), ec); - } + performance_counters::counter_path_elements paths; + performance_counters::get_counter_path_elements( + info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - // the counter is not available yet, create surrogate function - return performance_counters::detail::create_raw_counter( - info, num_messages_counter_surrogate(paths.parameters_), ec); + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_messages_counter_creator", + "invalid counter name for number of parcels (instance " + "name must not be a valid base counter name)"); + return naming::invalid_gid; } - break; - default: + if (paths.parameters_.empty()) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "num_messages_counter_creator", - "invalid counter type requested"); + "invalid counter parameter for number of parcels: must " + "specify an action type"); return naming::invalid_gid; } + + // ask registry + hpx::function f = + coalescing_counter_registry::instance().get_messages_counter( + paths.parameters_); + + if (!f.empty()) + { + return performance_counters::detail::create_raw_counter( + info, HPX_MOVE(f), ec); + } + + // the counter is not available yet, create surrogate function + return performance_counters::detail::create_raw_counter( + info, num_messages_counter_surrogate(paths.parameters_), ec); } /////////////////////////////////////////////////////////////////////////// @@ -257,58 +249,52 @@ namespace hpx::plugins::parcel { hpx::performance_counters::counter_info const& info, hpx::error_code& ec) { - switch (info.type_) - { - case performance_counters::counter_type::average_count: + if (info.type_ != performance_counters::counter_type::average_count) { - performance_counters::counter_path_elements paths; - performance_counters::get_counter_path_elements( - info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_parcels_per_message_counter_creator", - "invalid counter name for number of parcels (instance " - "name must not be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "num_parcels_per_message_counter_creator", - "invalid counter parameter for number of parcels: must " - "specify an action type"); - return naming::invalid_gid; - } - - // ask registry - hpx::function f = - coalescing_counter_registry::instance() - .get_parcels_per_message_counter(paths.parameters_); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_parcels_per_message_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - if (!f.empty()) - { - return performance_counters::detail::create_raw_counter( - info, HPX_MOVE(f), ec); - } + performance_counters::counter_path_elements paths; + performance_counters::get_counter_path_elements( + info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - // the counter is not available yet, create surrogate function - return performance_counters::detail::create_raw_counter(info, - num_parcels_per_message_counter_surrogate(paths.parameters_), - ec); + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "num_parcels_per_message_counter_creator", + "invalid counter name for number of parcels (instance " + "name must not be a valid base counter name)"); + return naming::invalid_gid; } - break; - default: + if (paths.parameters_.empty()) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "num_parcels_per_message_counter_creator", - "invalid counter type requested"); + "invalid counter parameter for number of parcels: must " + "specify an action type"); return naming::invalid_gid; } + + // ask registry + hpx::function f = + coalescing_counter_registry::instance() + .get_parcels_per_message_counter(paths.parameters_); + + if (!f.empty()) + { + return performance_counters::detail::create_raw_counter( + info, HPX_MOVE(f), ec); + } + + // the counter is not available yet, create surrogate function + return performance_counters::detail::create_raw_counter(info, + num_parcels_per_message_counter_surrogate(paths.parameters_), ec); } /////////////////////////////////////////////////////////////////////////// @@ -343,60 +329,53 @@ namespace hpx::plugins::parcel { hpx::performance_counters::counter_info const& info, hpx::error_code& ec) { - switch (info.type_) + if (info.type_ != performance_counters::counter_type::average_timer) { - case performance_counters::counter_type::average_timer: - { - performance_counters::counter_path_elements paths; - performance_counters::get_counter_path_elements( - info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "average_time_between_parcels_counter_creator", - "invalid counter name for number of parcels (instance " - "name must not be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "average_time_between_parcels_counter_creator", - "invalid counter parameter for number of parcels: must " - "specify an action type"); - return naming::invalid_gid; - } - - // ask registry - hpx::function f = - coalescing_counter_registry::instance() - .get_average_time_between_parcels_counter( - paths.parameters_); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "average_time_between_parcels_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - if (!f.empty()) - { - return performance_counters::detail::create_raw_counter( - info, HPX_MOVE(f), ec); - } + performance_counters::counter_path_elements paths; + performance_counters::get_counter_path_elements( + info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - // the counter is not available yet, create surrogate function - return performance_counters::detail::create_raw_counter(info, - average_time_between_parcels_counter_surrogate( - paths.parameters_), - ec); + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "average_time_between_parcels_counter_creator", + "invalid counter name for number of parcels (instance " + "name must not be a valid base counter name)"); + return naming::invalid_gid; } - break; - default: + if (paths.parameters_.empty()) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "average_time_between_parcels_counter_creator", - "invalid counter type requested"); + "invalid counter parameter for number of parcels: must " + "specify an action type"); return naming::invalid_gid; } + + // ask registry + hpx::function f = + coalescing_counter_registry::instance() + .get_average_time_between_parcels_counter(paths.parameters_); + + if (!f.empty()) + { + return performance_counters::detail::create_raw_counter( + info, HPX_MOVE(f), ec); + } + + // the counter is not available yet, create surrogate function + return performance_counters::detail::create_raw_counter(info, + average_time_between_parcels_counter_surrogate(paths.parameters_), + ec); } /////////////////////////////////////////////////////////////////////////// @@ -467,89 +446,84 @@ namespace hpx::plugins::parcel { hpx::performance_counters::counter_info const& info, hpx::error_code& ec) { - switch (info.type_) + if (info.type_ != performance_counters::counter_type::histogram) { - case performance_counters::counter_type::histogram: - { - performance_counters::counter_path_elements paths; - performance_counters::get_counter_path_elements( - info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "time_between_parcels_histogram_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "time_between_parcels_histogram_counter_creator", - "invalid counter name for " - "time-between-parcels histogram (instance " - "name must not be a valid base counter name)"); - return naming::invalid_gid; - } + performance_counters::counter_path_elements paths; + performance_counters::get_counter_path_elements( + info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "time_between_parcels_histogram_counter_creator", - "invalid counter parameter for " - "time-between-parcels histogram: must " - "specify an action type"); - return naming::invalid_gid; - } + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "time_between_parcels_histogram_counter_creator", + "invalid counter name for " + "time-between-parcels histogram (instance " + "name must not be a valid base counter name)"); + return naming::invalid_gid; + } - // split parameters, extract separate values - std::vector params; - hpx::string_util::split(params, paths.parameters_, - hpx::string_util::is_any_of(","), - hpx::string_util::token_compress_mode::off); + if (paths.parameters_.empty()) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "time_between_parcels_histogram_counter_creator", + "invalid counter parameter for " + "time-between-parcels histogram: must " + "specify an action type"); + return naming::invalid_gid; + } - std::int64_t min_boundary = 0; - std::int64_t max_boundary = 1000000; // 1ms - std::int64_t num_buckets = 20; + // split parameters, extract separate values + std::vector params; + hpx::string_util::split(params, paths.parameters_, + hpx::string_util::is_any_of(","), + hpx::string_util::token_compress_mode::off); - if (params.empty() || params[0].empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "time_between_parcels_histogram_counter_creator", - "invalid counter parameter for " - "time-between-parcels histogram: " - "must specify an action type"); - return naming::invalid_gid; - } + std::int64_t min_boundary = 0; + std::int64_t max_boundary = 1000000; // 1ms + std::int64_t num_buckets = 20; - if (params.size() > 1 && !params[1].empty()) - min_boundary = util::from_string(params[1]); - if (params.size() > 2 && !params[2].empty()) - max_boundary = util::from_string(params[2]); - if (params.size() > 3 && !params[3].empty()) - num_buckets = util::from_string(params[3]); + if (params.empty() || params[0].empty()) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "time_between_parcels_histogram_counter_creator", + "invalid counter parameter for " + "time-between-parcels histogram: " + "must specify an action type"); + return naming::invalid_gid; + } - // ask registry - hpx::function(bool)> f = - coalescing_counter_registry::instance() - .get_time_between_parcels_histogram_counter( - params[0], min_boundary, max_boundary, num_buckets); + if (params.size() > 1 && !params[1].empty()) + min_boundary = util::from_string(params[1]); + if (params.size() > 2 && !params[2].empty()) + max_boundary = util::from_string(params[2]); + if (params.size() > 3 && !params[3].empty()) + num_buckets = util::from_string(params[3]); - if (!f.empty()) - { - return performance_counters::detail::create_raw_counter( - info, HPX_MOVE(f), ec); - } + // ask registry + hpx::function(bool)> f = + coalescing_counter_registry::instance() + .get_time_between_parcels_histogram_counter( + params[0], min_boundary, max_boundary, num_buckets); - // the counter is not available yet, create surrogate function - return performance_counters::detail::create_raw_counter(info, - time_between_parcels_histogram_counter_surrogate( - params[0], min_boundary, max_boundary, num_buckets), - ec); + if (!f.empty()) + { + return performance_counters::detail::create_raw_counter( + info, HPX_MOVE(f), ec); } - break; - default: - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "time_between_parcels_histogram_counter_creator", - "invalid counter type requested"); - return naming::invalid_gid; - } + // the counter is not available yet, create surrogate function + return performance_counters::detail::create_raw_counter(info, + time_between_parcels_histogram_counter_surrogate( + params[0], min_boundary, max_boundary, num_buckets), + ec); } /////////////////////////////////////////////////////////////////////////// @@ -608,8 +582,7 @@ namespace hpx::plugins::parcel { // Install the counter types, un-installation of the types is handled // automatically. - install_counter_types( - counter_types, sizeof(counter_types) / sizeof(counter_types[0])); + install_counter_types(counter_types, std::size(counter_types)); } /////////////////////////////////////////////////////////////////////////// diff --git a/libs/core/command_line_handling_local/include/hpx/command_line_handling_local/parse_command_line_local.hpp b/libs/core/command_line_handling_local/include/hpx/command_line_handling_local/parse_command_line_local.hpp index ba7ebc417d24..c639ef6b8e99 100644 --- a/libs/core/command_line_handling_local/include/hpx/command_line_handling_local/parse_command_line_local.hpp +++ b/libs/core/command_line_handling_local/include/hpx/command_line_handling_local/parse_command_line_local.hpp @@ -20,9 +20,9 @@ namespace hpx::util { enum class commandline_error_mode : std::uint8_t { - return_on_error, - rethrow_on_error, - allow_unregistered, + return_on_error = 1, + rethrow_on_error = 2, + allow_unregistered = 3, ignore_aliases = 0x40, report_missing_config_file = 0x80 }; diff --git a/libs/core/errors/include/hpx/errors/error.hpp b/libs/core/errors/include/hpx/errors/error.hpp index 16b62c7f1b9a..c433a0f932bd 100644 --- a/libs/core/errors/include/hpx/errors/error.hpp +++ b/libs/core/errors/include/hpx/errors/error.hpp @@ -78,7 +78,7 @@ namespace hpx { assertion_failure = 25, ///< null_thread_id = 26, - ///< Attempt to invoke a API function from a non-HPX thread + ///< Attempt to invoke an API function from a non-HPX thread invalid_data = 27, ///< yield_aborted = 28, @@ -142,7 +142,7 @@ namespace hpx { ///< race, retry /// \cond NOINTERNAL - last_error, + last_error = 57, system_error_flag = 0x4000L, diff --git a/libs/core/program_options/src/utf8_codecvt_facet.cpp b/libs/core/program_options/src/utf8_codecvt_facet.cpp index 67aad71783df..0ae3df672381 100644 --- a/libs/core/program_options/src/utf8_codecvt_facet.cpp +++ b/libs/core/program_options/src/utf8_codecvt_facet.cpp @@ -16,6 +16,7 @@ #include #include +#include #include // for multi-byte conversion routines #include @@ -63,7 +64,7 @@ namespace hpx::program_options::detail { // number of "continuing octets" encoding the character int const cont_octet_count = static_cast(get_cont_octet_count(*from)); - const wchar_t octet1_modifier_table[] = { + wchar_t const octet1_modifier_table[] = { 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}; // The unsigned char conversion is necessary in case char is @@ -117,14 +118,15 @@ namespace hpx::program_options::detail { wchar_t const*& from_next, char* to, char* to_end, char*& to_next) const { // RG - consider merging this table with the other one - const wchar_t octet1_modifier_table[] = { + wchar_t const octet1_modifier_table[] = { 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}; constexpr wchar_t max_wchar = (std::numeric_limits::max)(); while (from != from_end && to != to_end) { // Check for invalid UCS-4 character - if (*from > max_wchar) + if (static_cast(*from) > + static_cast(max_wchar)) { from_next = from; to_next = to; @@ -134,7 +136,7 @@ namespace hpx::program_options::detail { int const cont_octet_count = get_cont_octet_out_count(*from); // RG - comment this formula better - int shift_exponent = (cont_octet_count) *6; + int shift_exponent = cont_octet_count * 6; // Process the first character *to++ = static_cast(octet1_modifier_table[cont_octet_count] + diff --git a/libs/core/runtime_local/include/hpx/runtime_local/os_thread_type.hpp b/libs/core/runtime_local/include/hpx/runtime_local/os_thread_type.hpp index 929a9a258a07..21bece24b15c 100644 --- a/libs/core/runtime_local/include/hpx/runtime_local/os_thread_type.hpp +++ b/libs/core/runtime_local/include/hpx/runtime_local/os_thread_type.hpp @@ -19,12 +19,12 @@ namespace hpx::runtime_local { enum class os_thread_type { unknown = -1, - main_thread = 0, ///< kernel thread represents main thread - worker_thread, ///< kernel thread is used to schedule HPX threads - io_thread, ///< kernel thread can be used for IO operations - timer_thread, ///< kernel is used by timer operations - parcel_thread, ///< kernel is used by networking operations - custom_thread ///< kernel is registered by the application + main_thread = 0, ///< kernel thread represents main thread + worker_thread = 1, ///< kernel thread is used to schedule HPX threads + io_thread = 2, ///< kernel thread can be used for IO operations + timer_thread = 3, ///< kernel is used by timer operations + parcel_thread = 4, ///< kernel is used by networking operations + custom_thread = 5 ///< kernel is registered by the application }; /// Return a human-readable name representing one of the kernel thread types diff --git a/libs/core/thread_pools/src/detail/background_thread.cpp b/libs/core/thread_pools/src/detail/background_thread.cpp index 4982df481111..ff5727edcb6e 100644 --- a/libs/core/thread_pools/src/detail/background_thread.cpp +++ b/libs/core/thread_pools/src/detail/background_thread.cpp @@ -118,7 +118,8 @@ namespace hpx::threads::detail { // allow to change the state the thread will be switched to after // execution - thread_state operator=(thread_result_type&& new_state) noexcept + switch_status_background& operator=( + thread_result_type&& new_state) noexcept { prev_state_ = thread_state( new_state.first, prev_state_.state_ex(), prev_state_.tag() + 1); @@ -126,7 +127,7 @@ namespace hpx::threads::detail { { next_thread_id_ = HPX_MOVE(new_state.second); } - return prev_state_; + return *this; } // Get the state this thread was in before execution (usually pending), diff --git a/libs/core/threading_base/include/hpx/threading_base/detail/switch_status.hpp b/libs/core/threading_base/include/hpx/threading_base/detail/switch_status.hpp index 6a735c0f8f0c..f9d4b47d9238 100644 --- a/libs/core/threading_base/include/hpx/threading_base/detail/switch_status.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/detail/switch_status.hpp @@ -48,7 +48,7 @@ namespace hpx::threads::detail { // allow to change the state the thread will be switched to after // execution - thread_state operator=(thread_result_type&& new_state) noexcept + switch_status& operator=(thread_result_type&& new_state) noexcept { prev_state_ = thread_state( new_state.first, prev_state_.state_ex(), prev_state_.tag() + 1); @@ -56,7 +56,7 @@ namespace hpx::threads::detail { { next_thread_id_ = HPX_MOVE(new_state.second); } - return prev_state_; + return *this; } // Get the state this thread was in before execution (usually pending), diff --git a/libs/core/threading_base/src/register_thread.cpp b/libs/core/threading_base/src/register_thread.cpp index b8184162d40b..226c970e6235 100644 --- a/libs/core/threading_base/src/register_thread.cpp +++ b/libs/core/threading_base/src/register_thread.cpp @@ -28,9 +28,11 @@ namespace hpx::threads { // run and free all registered exit functions for this thread auto* p = get_self_id_data(); - - p->run_thread_exit_callbacks(); - p->free_thread_exit_callbacks(); + if (HPX_LIKELY(p != nullptr)) + { + p->run_thread_exit_callbacks(); + p->free_thread_exit_callbacks(); + } return threads::thread_result_type( threads::thread_schedule_state::terminated, diff --git a/libs/full/init_runtime/src/hpx_init.cpp b/libs/full/init_runtime/src/hpx_init.cpp index 92485a237984..eb28a983f2f0 100644 --- a/libs/full/init_runtime/src/hpx_init.cpp +++ b/libs/full/init_runtime/src/hpx_init.cpp @@ -968,15 +968,12 @@ namespace hpx { // Command line handling should have updated this by now. HPX_ASSERT(cmdline.rtcfg_.mode_ != runtime_mode::default_); - switch (cmdline.rtcfg_.mode_) - { - case runtime_mode::local: + if (cmdline.rtcfg_.mode_ == runtime_mode::local) { LPROGRESS_ << "creating local runtime"; rt.reset(new hpx::runtime(cmdline.rtcfg_, true)); - break; } - default: + else { #if defined(HPX_HAVE_DISTRIBUTED_RUNTIME) for (auto const& registry : component_registries) @@ -989,7 +986,6 @@ namespace hpx { LPROGRESS_ << "creating distributed runtime"; rt.reset(new hpx::runtime_distributed(cmdline.rtcfg_, &hpx::detail::pre_main, &hpx::detail::post_main)); - break; #else HPX_THROW_EXCEPTION(hpx::error::invalid_status, "run_or_start", @@ -1000,10 +996,8 @@ namespace hpx { "Recompile HPX with HPX_WITH_DISTRIBUTED_RUNTIME=ON or " "change the runtime mode.", get_runtime_mode_name(cmdline.rtcfg_.mode_)); - break; #endif } - } // Store application defined command line options rt->set_app_options(params.desc_cmdline); diff --git a/libs/full/parcelport_tcp/src/connection_handler_tcp.cpp b/libs/full/parcelport_tcp/src/connection_handler_tcp.cpp index a6f997dd44f4..e4e81a285c38 100644 --- a/libs/full/parcelport_tcp/src/connection_handler_tcp.cpp +++ b/libs/full/parcelport_tcp/src/connection_handler_tcp.cpp @@ -81,6 +81,7 @@ namespace hpx::parcelset::policies::tcp { connection_handler::~connection_handler() { HPX_ASSERT(acceptor_ == nullptr); + delete acceptor_; // silence overeager security reports } bool connection_handler::do_run() diff --git a/libs/full/performance_counters/include/hpx/performance_counters/server/arithmetics_counter_extended.hpp b/libs/full/performance_counters/include/hpx/performance_counters/server/arithmetics_counter_extended.hpp index 8d108844d88e..52eaed78d1cf 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/server/arithmetics_counter_extended.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/server/arithmetics_counter_extended.hpp @@ -17,7 +17,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { /////////////////////////////////////////////////////////////////////////// // This counter exposes the result of an arithmetic operation The counter @@ -56,4 +56,4 @@ namespace hpx { namespace performance_counters { namespace server { // base counters to be queried performance_counter_set counters_; }; -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/src/server/action_invocation_counter.cpp b/libs/full/performance_counters/src/server/action_invocation_counter.cpp index ac9bcdae0136..aa9f3b026c24 100644 --- a/libs/full/performance_counters/src/server/action_invocation_counter.cpp +++ b/libs/full/performance_counters/src/server/action_invocation_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -15,7 +15,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { +namespace hpx::performance_counters { /////////////////////////////////////////////////////////////////////////// // Discoverer function for action invocation counters @@ -68,47 +68,42 @@ namespace hpx { namespace performance_counters { hpx::actions::detail::invocation_count_registry& registry, error_code& ec) { - switch (info.type_) + if (info.type_ != counter_type::monotonically_increasing) { - case counter_type::monotonically_increasing: + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "action_invocation_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } + + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; + + if (paths.parentinstance_is_basename_) { - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "action_invocation_counter_creator", - "invalid action invocation counter name (instance name " - "must not be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "action_invocation_counter_creator", - "invalid action invocation counter parameter: must " - "specify an action type"); - return naming::invalid_gid; - } - - // ask registry - hpx::function f = - registry.get_invocation_counter(paths.parameters_); - - return detail::create_raw_counter(info, HPX_MOVE(f), ec); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "action_invocation_counter_creator", + "invalid action invocation counter name (instance name " + "must not be a valid base counter name)"); + return naming::invalid_gid; } - break; - default: + if (paths.parameters_.empty()) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "action_invocation_counter_creator", - "invalid counter type requested"); + "invalid action invocation counter parameter: must " + "specify an action type"); return naming::invalid_gid; } + + // ask registry + hpx::function f = + registry.get_invocation_counter(paths.parameters_); + + return detail::create_raw_counter(info, HPX_MOVE(f), ec); } naming::gid_type local_action_invocation_counter_creator( @@ -128,4 +123,4 @@ namespace hpx { namespace performance_counters { info, invocation_count_registry::remote_instance(), ec); } #endif -}} // namespace hpx::performance_counters +} // namespace hpx::performance_counters diff --git a/libs/full/performance_counters/src/server/arithmetics_counter.cpp b/libs/full/performance_counters/src/server/arithmetics_counter.cpp index d5ec5894d8b0..0775a3245351 100644 --- a/libs/full/performance_counters/src/server/arithmetics_counter.cpp +++ b/libs/full/performance_counters/src/server/arithmetics_counter.cpp @@ -230,66 +230,63 @@ namespace hpx::performance_counters::detail { naming::gid_type arithmetics_counter_creator( counter_info const& info, error_code& ec) { - switch (info.type_) + if (info.type_ != counter_type::aggregating) { - case counter_type::aggregating: + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_creator", + "invalid counter type requested"); + + return naming::invalid_gid; + } + + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; + + if (!paths.parameters_.empty()) { - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; + // try to interpret the additional parameter as a list of + // two performance counter names + std::vector names; + hpx::string_util::split( + names, paths.parameters_, hpx::string_util::is_any_of(",")); - if (!paths.parameters_.empty()) + if (names.empty()) { - // try to interpret the additional parameter as a list of - // two performance counter names - std::vector names; - hpx::string_util::split( - names, paths.parameters_, hpx::string_util::is_any_of(",")); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_creator", + "the parameter specification for an arithmetic counter " + "has to expand to at least one counter name: {}", + paths.parameters_); + return naming::invalid_gid; + } - if (names.empty()) + for (std::string const& name : names) + { + if (counter_status::valid_data != + get_counter_path_elements(name, paths, ec) || + ec) { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "arithmetics_counter_creator", - "the parameter specification for an arithmetic counter " - "has to expand to at least one counter name: {}", - paths.parameters_); + "the given (expanded) counter name is not " + "a validly formed performance counter name: {}", + name); return naming::invalid_gid; } - - for (std::string const& name : names) - { - if (counter_status::valid_data != - get_counter_path_elements(name, paths, ec) || - ec) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_creator", - "the given (expanded) counter name is not " - "a validly formed performance counter name: {}", - name); - return naming::invalid_gid; - } - } - - return create_arithmetics_counter(info, names, ec); } - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_creator", - "the parameter specification for an arithmetic counter " - "has to be a comma separated list of performance " - "counter names, none is given: {}", - remove_counter_prefix(info.fullname_)); + return create_arithmetics_counter(info, names, ec); } - break; - default: - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_creator", - "invalid counter type requested"); - break; - } + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_creator", + "the parameter specification for an arithmetic counter " + "has to be a comma separated list of performance " + "counter names, none is given: {}", + remove_counter_prefix(info.fullname_)); + return naming::invalid_gid; } } // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp b/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp index c04ca8b7b67d..f75f04aea5df 100644 --- a/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp +++ b/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp @@ -275,74 +275,67 @@ HPX_DEFINE_GET_COMPONENT_TYPE(count_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// namespace hpx::performance_counters::detail { - /// Creation function for aggregating performance counters to be registered - /// with the counter types. + // Creation function for aggregating performance counters to be registered + // with the counter types. naming::gid_type arithmetics_counter_extended_creator( counter_info const& info, error_code& ec) { - switch (info.type_) + if (info.type_ != counter_type::aggregating) { - case counter_type::aggregating: + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_extended_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } + + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; + + if (!paths.parameters_.empty()) { - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; + // try to interpret the additional parameter as a list of + // two performance counter names + std::vector names; + hpx::string_util::split( + names, paths.parameters_, hpx::string_util::is_any_of(",")); - if (!paths.parameters_.empty()) + if (names.empty()) { - // try to interpret the additional parameter as a list of - // two performance counter names - std::vector names; - hpx::string_util::split( - names, paths.parameters_, hpx::string_util::is_any_of(",")); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_extended_creator", + "the parameter specification for an arithmetic counter " + "has to expand to at least one counter name: {}", + paths.parameters_); + return naming::invalid_gid; + } - if (names.empty()) + for (std::string const& name : names) + { + counter_path_elements paths; + if (counter_status::valid_data != + get_counter_path_elements(name, paths, ec) || + ec) { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "arithmetics_counter_extended_creator", - "the parameter specification for an arithmetic counter " - "has to expand to at least one counter name: {}", - paths.parameters_); + "the given (expanded) counter name is not " + "a validly formed performance counter name: {}", + name); return naming::invalid_gid; } - - for (std::string const& name : names) - { - counter_path_elements paths; - if (counter_status::valid_data != - get_counter_path_elements(name, paths, ec) || - ec) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_extended_creator", - "the given (expanded) counter name is not " - "a validly formed performance counter name: {}", - name); - return naming::invalid_gid; - } - } - - return create_arithmetics_counter_extended(info, names, ec); - } - else - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_extended_creator", - "the parameter specification for an arithmetic counter " - "has to be a comma separated list of performance " - "counter names, none is given: {}", - remove_counter_prefix(info.fullname_)); } - } - break; - default: - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_extended_creator", - "invalid counter type requested"); - break; + return create_arithmetics_counter_extended(info, names, ec); } + + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_extended_creator", + "the parameter specification for an arithmetic counter " + "has to be a comma separated list of performance " + "counter names, none is given: {}", + remove_counter_prefix(info.fullname_)); return naming::invalid_gid; } } // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/component_instance_counter.cpp b/libs/full/performance_counters/src/server/component_instance_counter.cpp index 1f03c02da41d..ece78e42297b 100644 --- a/libs/full/performance_counters/src/server/component_instance_counter.cpp +++ b/libs/full/performance_counters/src/server/component_instance_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2019 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -17,7 +17,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace detail { +namespace hpx::performance_counters::detail { /////////////////////////////////////////////////////////////////////////// // Extract the current number of instances for the given component type @@ -31,68 +31,62 @@ namespace hpx { namespace performance_counters { namespace detail { naming::gid_type component_instance_counter_creator( counter_info const& info, error_code& ec) { - switch (info.type_) + if (info.type_ != counter_type::raw) { - case counter_type::raw: - { - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "component_instance_counter_creator", - "invalid instance counter name (instance name must not " - "be a valid base counter name)"); - return naming::invalid_gid; - } - - if (paths.parameters_.empty()) - { - std::stringstream strm; - strm << "invalid instance counter parameter: must specify " - "a component type\n" - "known component types:\n"; + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "component_instance_counter_creator", + "invalid counter type requested"); + return naming::invalid_gid; + } - components::enumerate_instance_counts( - [&strm](components::component_type type) -> bool { - strm << " " << agas::get_component_type_name(type) - << "\n"; - return true; - }); + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "component_instance_counter_creator", strm.str()); + if (paths.parentinstance_is_basename_) + { + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "component_instance_counter_creator", + "invalid instance counter name (instance name must not " + "be a valid base counter name)"); + return naming::invalid_gid; + } - return naming::invalid_gid; - } + if (paths.parameters_.empty()) + { + std::stringstream strm; + strm << "invalid instance counter parameter: must specify " + "a component type\n" + "known component types:\n"; - // ask AGAS to resolve the component type - components::component_type type = - agas::get_component_id(paths.parameters_); + components::enumerate_instance_counts( + [&strm](components::component_type type) -> bool { + strm << " " << agas::get_component_type_name(type) << "\n"; + return true; + }); - if (type == to_int(hpx::components::component_enum_type::invalid)) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "component_instance_counter_creator", - "invalid component type as counter parameter: {}", - paths.parameters_); - return naming::invalid_gid; - } + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "component_instance_counter_creator", strm.str()); - hpx::function f = - hpx::bind_front(&get_instance_count, type); - return create_raw_counter(info, HPX_MOVE(f), ec); + return naming::invalid_gid; } - break; - default: + // ask AGAS to resolve the component type + components::component_type type = + agas::get_component_id(paths.parameters_); + + if (type == to_int(hpx::components::component_enum_type::invalid)) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "component_instance_counter_creator", - "invalid counter type requested"); + "invalid component type as counter parameter: {}", + paths.parameters_); return naming::invalid_gid; } + + hpx::function f = + hpx::bind_front(&get_instance_count, type); + return create_raw_counter(info, HPX_MOVE(f), ec); } -}}} // namespace hpx::performance_counters::detail +} // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/elapsed_time_counter.cpp b/libs/full/performance_counters/src/server/elapsed_time_counter.cpp index 5396ac712032..349cc7ab1bcc 100644 --- a/libs/full/performance_counters/src/server/elapsed_time_counter.cpp +++ b/libs/full/performance_counters/src/server/elapsed_time_counter.cpp @@ -101,34 +101,30 @@ namespace hpx::performance_counters::detail { naming::gid_type uptime_counter_creator( counter_info const& info, error_code& ec) { - switch (info.type_) - { - case counter_type::elapsed_time: + if (info.type_ != counter_type::elapsed_time) { - // verify the validity of the counter instance name - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; - - // allowed counter names: /runtime(locality#%d/*)/uptime - if (paths.parentinstance_is_basename_) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "uptime_counter_creator", - "invalid counter instance parent name: {}", - paths.parentinstancename_); - return naming::invalid_gid; - } - - // create the counter - return create_counter(info, ec); + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "uptime_counter_creator", "invalid counter type requested"); + return naming::invalid_gid; } - default: + // verify the validity of the counter instance name + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; + + // allowed counter names: /runtime(locality#%d/*)/uptime + if (paths.parentinstance_is_basename_) + { HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "uptime_counter_creator", "invalid counter type requested"); + "uptime_counter_creator", + "invalid counter instance parent name: {}", + paths.parentinstancename_); return naming::invalid_gid; } + + // create the counter + return create_counter(info, ec); } } // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/statistics_counter.cpp b/libs/full/performance_counters/src/server/statistics_counter.cpp index b965875bf5f9..d41c0130c226 100644 --- a/libs/full/performance_counters/src/server/statistics_counter.cpp +++ b/libs/full/performance_counters/src/server/statistics_counter.cpp @@ -755,57 +755,50 @@ namespace hpx::performance_counters::detail { naming::gid_type statistics_counter_creator( counter_info const& info, error_code& ec) { - switch (info.type_) + if (info.type_ != counter_type::aggregating) { - case counter_type::aggregating: + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "statistics_counter_creator", "invalid counter type requested"); + return naming::invalid_gid; + } + + counter_path_elements paths; + get_counter_path_elements(info.fullname_, paths, ec); + if (ec) + return naming::invalid_gid; + + if (!paths.parentinstance_is_basename_) { - counter_path_elements paths; - get_counter_path_elements(info.fullname_, paths, ec); - if (ec) - return naming::invalid_gid; + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "statistics_counter_creator", + "invalid aggregate counter " + "name (instance name must be valid base counter name)"); + return naming::invalid_gid; + } + + std::string base_name; + get_counter_name(paths.parentinstancename_, base_name, ec); + if (ec) + return naming::invalid_gid; - if (!paths.parentinstance_is_basename_) + std::vector parameters; + if (!paths.parameters_.empty()) + { + // try to interpret the additional parameters + namespace x3 = boost::spirit::x3; + if (!x3::parse(paths.parameters_.begin(), paths.parameters_.end(), + x3::uint_ % ',', parameters)) { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "statistics_counter_creator", - "invalid aggregate counter " - "name (instance name must be valid base counter name)"); + "invalid parameter specification format for " + "this counter: {}", + paths.parameters_); return naming::invalid_gid; } - - std::string base_name; - get_counter_name(paths.parentinstancename_, base_name, ec); - if (ec) - return naming::invalid_gid; - - std::vector parameters; - if (!paths.parameters_.empty()) + if (paths.countername_.find("rolling") != std::string::npos) { - // try to interpret the additional parameters - namespace x3 = boost::spirit::x3; - if (!x3::parse(paths.parameters_.begin(), - paths.parameters_.end(), x3::uint_ % ',', parameters)) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "statistics_counter_creator", - "invalid parameter specification format for " - "this counter: {}", - paths.parameters_); - return naming::invalid_gid; - } - if (paths.countername_.find("rolling") != std::string::npos) - { - if (parameters.size() > 3) - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "statistics_counter_creator", - "too many parameter specifications for " - "this counter: {}", - paths.parameters_); - return naming::invalid_gid; - } - } - else if (parameters.size() > 2) + if (parameters.size() > 3) { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "statistics_counter_creator", @@ -815,25 +808,28 @@ namespace hpx::performance_counters::detail { return naming::invalid_gid; } } - else if (paths.countername_.find("rolling") != std::string::npos) + else if (parameters.size() > 2) { - parameters.push_back(1000); // sample interval - parameters.push_back(10); // rolling window - parameters.push_back(0); // don't reset underlying counter - } - else - { - parameters.push_back(1000); // sample interval - parameters.push_back(0); // don't reset underlying counter + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "statistics_counter_creator", + "too many parameter specifications for " + "this counter: {}", + paths.parameters_); + return naming::invalid_gid; } - return create_statistics_counter(info, base_name, parameters, ec); } - break; - - default: - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "statistics_counter_creator", "invalid counter type requested"); - return naming::invalid_gid; + else if (paths.countername_.find("rolling") != std::string::npos) + { + parameters.push_back(1000); // sample interval + parameters.push_back(10); // rolling window + parameters.push_back(0); // don't reset underlying counter } + else + { + parameters.push_back(1000); // sample interval + parameters.push_back(0); // don't reset underlying counter + } + + return create_statistics_counter(info, base_name, parameters, ec); } } // namespace hpx::performance_counters::detail