Skip to content

Commit bd20e7b

Browse files
committed
rgw/asio: add scope guard warn_about_blocking_in_scope
Signed-off-by: Casey Bodley <[email protected]>
1 parent 1976d67 commit bd20e7b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/rgw/rgw_asio_thread.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#pragma once
1717

18+
#include <assert.h>
19+
1820
class DoutPrefixProvider;
1921

2022
/// indicates whether the current thread is in boost::asio::io_context::run(),
@@ -24,3 +26,14 @@ extern thread_local bool is_asio_thread;
2426
/// call when an operation will block the calling thread due to an empty
2527
/// optional_yield. a warning is logged when is_asio_thread is true
2628
void maybe_warn_about_blocking(const DoutPrefixProvider* dpp);
29+
30+
/// enables warnings while in scope. these scopes must not be nested
31+
struct warn_about_blocking_in_scope {
32+
warn_about_blocking_in_scope() {
33+
assert(!is_asio_thread);
34+
is_asio_thread = true;
35+
}
36+
~warn_about_blocking_in_scope() {
37+
is_asio_thread = false;
38+
}
39+
};

0 commit comments

Comments
 (0)