| Flutter Impeller |

thread_safety.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_BASE_THREAD_SAFETY_H_
6 #define FLUTTER_IMPELLER_BASE_THREAD_SAFETY_H_
7
8 #if defined(__clang__)
9 #define IPLR_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
10 #else
11 #define IPLR_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
12 #endif
13
14 #define IPLR_CAPABILITY(x) IPLR_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
15
16 #define IPLR_SCOPED_CAPABILITY \
17 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
18
19 #define IPLR_GUARDED_BY(x) IPLR_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
20
21 #define IPLR_PT_GUARDED_BY(x) \
22 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
23
24 #define IPLR_ACQUIRED_BEFORE(...) \
25 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
26
27 #define IPLR_ACQUIRED_AFTER(...) \
28 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
29
30 #define IPLR_REQUIRES(...) \
31 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
32
33 #define IPLR_REQUIRES_SHARED(...) \
34 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
35
36 #define IPLR_ACQUIRE(...) \
37 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
38
39 #define IPLR_ACQUIRE_SHARED(...) \
40 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
41
42 #define IPLR_RELEASE(...) \
43 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
44
45 #define IPLR_RELEASE_SHARED(...) \
46 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
47
48 #define IPLR_RELEASE_GENERIC(...) \
49 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
50
51 #define IPLR_TRY_ACQUIRE(...) \
52 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
53
54 #define IPLR_TRY_ACQUIRE_SHARED(...) \
55 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
56
57 #define IPLR_EXCLUDES(...) \
58 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
59
60 #define IPLR_ASSERT_CAPABILITY(x) \
61 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
62
63 #define IPLR_ASSERT_SHARED_CAPABILITY(x) \
64 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
65
66 #define IPLR_RETURN_CAPABILITY(x) \
67 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
68
69 #define IPLR_NO_THREAD_SAFETY_ANALYSIS \
70 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
71
72 #endif // FLUTTER_IMPELLER_BASE_THREAD_SAFETY_H_