Add a debug-only guard to check if code is running on the task runner
Change-Id: I10953bf5bb0c7f823c15d3bf3640a03a9c2ff43d
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1815070
Commit-Queue: Max Yakimakha <yakimakha@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
diff --git a/platform/api/task_runner.h b/platform/api/task_runner.h
index cc37f5e..b55a206 100644
--- a/platform/api/task_runner.h
+++ b/platform/api/task_runner.h
@@ -8,6 +8,7 @@
#include <future>
#include "absl/types/optional.h"
+#include "platform/api/logging.h"
#include "platform/api/time.h"
namespace openscreen {
@@ -47,6 +48,10 @@
// passing an existing Task object.
virtual void PostPackagedTask(Task task) = 0;
virtual void PostPackagedTaskWithDelay(Task task, Clock::duration delay) = 0;
+
+ // Return true if the calling thread is the thread that task runner is using
+ // to run tasks, false otherwise.
+ virtual bool IsRunningOnTaskRunner() = 0;
};
// Class used to post the same task repeatedly to the task runner, with the