add FunctionThread::RunInOtherThread
Change-Id: I6536ac1e7f409ba8c1dc4cbb1db27ca099983d90
diff --git a/aos/common/util/thread.h b/aos/common/util/thread.h
index bf90ce4..993e343 100644
--- a/aos/common/util/thread.h
+++ b/aos/common/util/thread.h
@@ -69,6 +69,13 @@
FunctionThread(::std::function<void(FunctionThread *)> function)
: function_(function) {}
+ // Runs function in a new thread and waits for it to return.
+ static void RunInOtherThread(::std::function<void()> function) {
+ FunctionThread t([&function](FunctionThread *) { function(); });
+ t.Start();
+ t.Join();
+ }
+
private:
virtual void Run() override {
function_(this);