8000 Feature/guarded mutex by goedderz · Pull Request #13996 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/guarded mutex #13996

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 24 commits into from
Jul 12, 2021
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
333d579
Began work on a value guarded by mutex implementation
goedderz Jul 9, 2019
4657757
Added (empty) test file
goedderz Jul 18, 2019
86ff2c1
A first test, and some fixes
goedderz Oct 9, 2019
08adbf4
Deleted copy&move constructors
goedderz Oct 10, 2019
ea01ee2
explicitly defaulted destructor
goedderz Oct 10, 2019
4326973
Switched to trailing return types
goedderz Oct 2, 2020
b8c7f3d
Some improvements and more tests
goedderz Nov 13, 2020
4c07156
Rename arangodb::Mutex::tryLock to make Mutex more compatible with st…
goedderz Nov 19, 2020
612aee7
Moved Guarded files to Basics
goedderz Nov 19, 2020
d691764
minor cleanup
goedderz Nov 19, 2020
1eec096
added comment
goedderz Nov 19, 2020
6ea04cc
parametrized lock
goedderz Nov 19, 2020
f01691e
added test assertions
goedderz Nov 20, 2020
a4e1735
Fixed windows, added a test
goedderz Nov 20, 2020
2d843dc
Added assign and copy
goedderz Nov 20, 2020
3971e76
Merge branch 'devel' of github.com:arangodb/arangodb into feature/gua…
goedderz Apr 16, 2021
09aa867
Add perfect forwarding in Guarded constructor
goedderz Apr 29, 2021
c206171
Merge branch 'devel' of github.com:arangodb/arangodb into feature/gua…
goedderz Jun 1, 2021
1561c4f
Backported some changes from replication-2.0
goedderz Jun 1, 2021
add04ec
Merge branch 'devel' of github.com:arangodb/arangodb into feature/gua…
goedderz Jun 29, 2021
c6668d3
Minor changes
goedderz Jun 29, 2021
ea89666
Added missing tests
goedderz Jun 29, 2021
52b76b3
Minor changes from review
goedderz Jul 9, 2021
d0ebb4c
Remove code duplication as suggested in the review
goedderz Jul 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added comment
  • Loading branch information
goedderz committed Nov 19, 2020
commit 1eec0966f1a7370948565b33ee3fedf9c69be6cb
31 changes: 31 additions & 0 deletions lib/Basics/Guarded.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@
#include <stdexcept>
#include <variant>

/**
* SYNOPSIS
*
* The class Guarded contains a value and an associated mutex. It does allow
* access to the value only while owning a lock to the mutex.
*
* For example, given a
*
* struct UnderGuard { int value; }
*
* , define a guarded object as follows:
*
* Guarded<UnderGuard> guarded(7);
*
* The constructor's arguments will be forwarded.
*
* It can either be accessed by passing a lambda:
*
* guarded.doUnderLock([](UnderGuard& obj) { obj.value = 12; });
*
* This will lock the mutex before the lambda's execution, and release it after.
*
* Or it can be accessed by creating a MutexGuard:
*
* auto mutexGuard = guarded.getLockedGuard();
* mutexGuard->value = 13;
*
* getLockedGuard() will lock the mutex, and mutexGuard will release 4DEF it upon
* destruction.
*/

namespace arangodb {

class Mutex;
Expand Down
0