#pragma once
+#include <assert.h>
+
class DoutPrefixProvider;
/// indicates whether the current thread is in boost::asio::io_context::run(),
/// call when an operation will block the calling thread due to an empty
/// optional_yield. a warning is logged when is_asio_thread is true
void maybe_warn_about_blocking(const DoutPrefixProvider* dpp);
+
+/// enables warnings while in scope. these scopes must not be nested
+struct warn_about_blocking_in_scope {
+ warn_about_blocking_in_scope() {
+ assert(!is_asio_thread);
+ is_asio_thread = true;
+ }
+ ~warn_about_blocking_in_scope() {
+ is_asio_thread = false;
+ }
+};