Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
f8262db9
Unverified
Commit
f8262db9
authored
May 31, 2018
by
Adam Cozzette
Committed by
GitHub
May 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4703 from acozzette/thread-safety-annotations
Added Clang thread-safety annotations in mutex.h
parents
cf242503
adc40869
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
mutex.h
src/google/protobuf/stubs/mutex.h
+17
-3
No files found.
src/google/protobuf/stubs/mutex.h
View file @
f8262db9
...
...
@@ -34,6 +34,18 @@
#include <google/protobuf/stubs/macros.h>
// Define thread-safety annotations for use below, if we are building with
// Clang.
#if defined(__clang__) && !defined(SWIG)
#define GOOGLE_PROTOBUF_ACQUIRE(...) \
__attribute__((acquire_capability(__VA_ARGS__)))
#define GOOGLE_PROTOBUF_RELEASE(...) \
__attribute__((release_capability(__VA_ARGS__)))
#else
#define GOOGLE_PROTOBUF_ACQUIRE(...)
#define GOOGLE_PROTOBUF_RELEASE(...)
#endif
// ===================================================================
// emulates google3/base/mutex.h
namespace
google
{
...
...
@@ -48,8 +60,8 @@ namespace internal {
class
LIBPROTOBUF_EXPORT
WrappedMutex
{
public
:
WrappedMutex
()
=
default
;
void
Lock
()
{
mu_
.
lock
();
}
void
Unlock
()
{
mu_
.
unlock
();
}
void
Lock
()
GOOGLE_PROTOBUF_ACQUIRE
()
{
mu_
.
lock
();
}
void
Unlock
()
GOOGLE_PROTOBUF_RELEASE
()
{
mu_
.
unlock
();
}
// Crash if this Mutex is not held exclusively by this thread.
// May fail to crash when it should; will never crash when it should not.
void
AssertHeld
()
const
{}
...
...
@@ -123,8 +135,10 @@ using internal::ReaderMutexLock;
using
internal
::
WriterMutexLock
;
using
internal
::
MutexLockMaybe
;
}
// namespace protobuf
}
// namespace google
#undef GOOGLE_PROTOBUF_ACQUIRE
#undef GOOGLE_PROTOBUF_RELEASE
#endif // GOOGLE_PROTOBUF_STUBS_MUTEX_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment