Skip to content

synchronized_value #3984

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jun 24, 2025
Merged

synchronized_value #3984

merged 39 commits into from
Jun 24, 2025

Conversation

Klaim
Copy link
Member

@Klaim Klaim commented Jun 12, 2025

Description

Adds an implementation of synchronized_value inspired by boost::thread::synchronized_value and the Concurrency TS 2's specifications. It doesnt follow these exactly for the advanced features but do so for the basic ones.

As there is a reticence to depend upon Boost, we decided it would be best to have an implementation at hand for libmamba's internals as we have many cases of tricky mutex handling. The logging split which is WIP will depon on this tool.

Supports shared mutex by using shared locking instead of normal/exclusive locking when the access is const.

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance
  • Internal tooling

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@Klaim Klaim added the release::maintenance For PRs related to maintenance label Jun 12, 2025
Copy link

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.83%. Comparing base (445bf87) to head (3d9248a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3984      +/-   ##
==========================================
- Coverage   63.86%   63.83%   -0.04%     
==========================================
  Files         300      302       +2     
  Lines       38220    38353     +133     
  Branches     2853     2855       +2     
==========================================
+ Hits        24411    24481      +70     
- Misses      13742    13805      +63     
  Partials       67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Klaim Klaim force-pushed the synchronized_value branch from 3d9248a to 3e511e9 Compare June 16, 2025 15:58
@Klaim Klaim changed the title synchronized_value helper type synchronized_value Jun 16, 2025
@Klaim Klaim force-pushed the synchronized_value branch from 3e511e9 to 911bc17 Compare June 17, 2025 17:19
@Klaim Klaim marked this pull request as ready for review June 17, 2025 17:21
@Klaim
Copy link
Member Author

Klaim commented Jun 17, 2025

A note about the documentation: doxygen's autobrief generates the brief from the first line (until the first dot) of the doxygen comments, so there is no need to add @brief, no need to add an empty first line etc.
I also used the less noisy doxygen comments form (* vertical is really not helping reading) and didnt use @param when the brief already describe enough of the behavior and the parameters are constrained enough.

@Klaim Klaim force-pushed the synchronized_value branch from 42cbba8 to 573daa4 Compare June 19, 2025 11:35
@Klaim
Copy link
Member Author

Klaim commented Jun 19, 2025

Looks like my local VS2022 (preview) has fixes that the CI doesnt have yet. I'll do some woarkaounds.

@Klaim Klaim force-pushed the synchronized_value branch from 24ea407 to e6e52e9 Compare June 19, 2025 13:54
template <Mutex M>
M& mutex_ref()
{
static M m;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why static?

Copy link
Member Author

@Klaim Klaim Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that function is only used in non-evaluated context so I just wrote that to avoid having to construct a mutex. In theory we could remove the definition I think.
But tu clarify: I needed a reference to be returned, not a r-value reference, not a moved-from, not a value. Returning a temporary would have not compiled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm I can just remove the definition, I'll push the change. I suspect there might be a standard tool to get what I wnat but I didnt find it , std::declval isnt it.

@JohanMabille JohanMabille merged commit 98b4877 into mamba-org:main Jun 24, 2025
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release::maintenance For PRs related to maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants