-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix race conditions in shard #4188
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef RIPPLE_BASICS_THREAD_SAFTY_ANALYSIS_H_INCLUDED | ||
#define RIPPLE_BASICS_THREAD_SAFTY_ANALYSIS_H_INCLUDED | ||
|
||
#ifdef RIPPLE_ENABLE_THREAD_SAFETY_ANNOTATIONS | ||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) | ||
#else | ||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op | ||
#endif | ||
|
||
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) | ||
|
||
#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) | ||
|
||
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) | ||
|
||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) | ||
|
||
#define ACQUIRED_BEFORE(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) | ||
|
||
#define ACQUIRED_AFTER(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) | ||
|
||
#define REQUIRES(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__)) | ||
|
||
#define REQUIRES_SHARED(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) | ||
|
||
#define ACQUIRE(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) | ||
|
||
#define ACQUIRE_SHARED(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) | ||
|
||
#define RELEASE(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) | ||
|
||
#define RELEASE_SHARED(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) | ||
|
||
#define RELEASE_GENERIC(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__)) | ||
|
||
#define TRY_ACQUIRE(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) | ||
|
||
#define TRY_ACQUIRE_SHARED(...) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) | ||
|
||
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) | ||
|
||
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) | ||
|
||
#define ASSERT_SHARED_CAPABILITY(x) \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) | ||
|
||
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) | ||
|
||
#define NO_THREAD_SAFETY_ANALYSIS \ | ||
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 really like this annotation! Could not be clearer.
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.
As a side note: one down side to these annotations being bolted-on and not part of the language is we usually put the annotations at the end of a declaration, but when the variable is initialized, we need to put it at the beginning. That's unfortunate, but not a killer.