File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,8 @@ template <typename OnViolationAction>
21
21
void ExpectNotRealtime (Context &context, OnViolationAction &&OnViolation) {
22
22
CHECK (__rtsan_is_initialized ());
23
23
if (context.InRealtimeContext () && !context.IsBypassed ()) {
24
- context. BypassPush () ;
24
+ ScopedBypass sb{ context} ;
25
25
OnViolation ();
26
- context.BypassPop ();
27
26
}
28
27
}
29
28
Original file line number Diff line number Diff line change @@ -35,5 +35,22 @@ class Context {
35
35
int bypass_depth_{0 };
36
36
};
37
37
38
+ class ScopedBypass {
39
+ public:
40
+ [[nodiscard]] explicit ScopedBypass (Context &context) : context_(context) {
41
+ context_.BypassPush ();
42
+ }
43
+
44
+ ~ScopedBypass () { context_.BypassPop (); }
45
+
46
+ ScopedBypass (const ScopedBypass &) = delete ;
47
+ ScopedBypass &operator =(const ScopedBypass &) = delete ;
48
+ ScopedBypass (ScopedBypass &&) = delete ;
49
+ ScopedBypass &operator =(ScopedBypass &&) = delete ;
50
+
51
+ private:
52
+ Context &context_;
53
+ };
54
+
38
55
Context &GetContextForThisThread ();
39
56
} // namespace __rtsan
You can’t perform that action at this time.
0 commit comments