-
Notifications
You must be signed in to change notification settings - Fork 396
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
synchronized_value
#3984
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
3d9248a
to
3e511e9
Compare
3e511e9
to
911bc17
Compare
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 |
42cbba8
to
573daa4
Compare
Looks like my local VS2022 (preview) has fixes that the CI doesnt have yet. I'll do some woarkaounds. |
24ea407
to
e6e52e9
Compare
template <Mutex M> | ||
M& mutex_ref() | ||
{ | ||
static M m; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why static?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Description
Adds an implementation of
synchronized_value
inspired byboost::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
Checklist
pre-commit run --all
locally in the source folder and confirmed that there are no linter errors.