Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow filtering a specific mutex for tracking with NANO_TIMED_LOCKS #2765

Merged
merged 12 commits into from
Mar 4, 2021

Conversation

wezrule
Copy link
Contributor

@wezrule wezrule commented May 7, 2020

This works by creating a wrapper around a std::mutex with a string constructor argument where a name for the mutex is specified. Users can register a mutex to track with the new NANO_TIMED_LOCKS_FILTER CMake variable, giving it a string matching one of the allowed mutex strings.

The actual files which changed are:
locks.hpp/cpp - Added nano::mutex class which has a constructor for passing in the name. In non NANO_TIMED_LOCKS builds, we want this class to have as little impact as possible (hence all the preprocessor guards).

CMakeLists.txt - Added new CMake variable NANO_TIMED_LOCKS_FILTER which currently allows any of ~20 named mutexes for tracking. I picked (I think) the most useful ones rather than add them all. Only a single one can be selected. Multiple is technically possible but not implemented here as theres a lot more value in targeting a specific one (due to interference due to slow generation of stacktraces on Windows for instance).

The mutexes which need tracking now use the new string constructor.

Updated core_tests/locks.cpp as if NANO_TIMED_LOCKS_FILTER is specified the tests would have otherwise failed fail.

Updated CI so that it is mandatory for nano::mutex to be used. It is not mandatory that it be named, the default constructor is fine to use.

@wezrule wezrule added enhancement debug Updates assisting with debugging and development efforts labels May 7, 2020
@wezrule wezrule added this to the V22.0 milestone May 7, 2020
@wezrule wezrule self-assigned this May 7, 2020
@wezrule wezrule marked this pull request as draft May 7, 2020 19:18
@wezrule wezrule added the documentation This item indicates the need for or supplies updated or expanded documentation label May 7, 2020
@ghost
Copy link

ghost commented Jan 5, 2021

DeepCode's analysis on #5cad3f found:

  • ℹ️ 1 minor issue. 👇

Top issues

Description Example fixes
Consider using a std::lock_guard object instead of locking and locking std::mutex explicitly. std::lock_guard will unlock the mutex once it runs out of scope and is destructed. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

@wezrule wezrule requested a review from SergiySW January 7, 2021 11:11
@wezrule wezrule marked this pull request as ready for review January 7, 2021 11:11
@wezrule wezrule merged commit b0f81d5 into nanocurrency:develop Mar 4, 2021
@wezrule wezrule deleted the filter_specific_mutex_tracking branch March 4, 2021 18:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
debug Updates assisting with debugging and development efforts documentation This item indicates the need for or supplies updated or expanded documentation enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants