summaryrefslogtreecommitdiff
path: root/src/task_runner_reply.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/task_runner_reply.hh')
-rw-r--r--src/task_runner_reply.hh19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/task_runner_reply.hh b/src/task_runner_reply.hh
new file mode 100644
index 0000000..1ca65a0
--- /dev/null
+++ b/src/task_runner_reply.hh
@@ -0,0 +1,19 @@
+#ifndef TASK_RUNNER_REPLY_HH
+#define TASK_RUNNER_REPLY_HH
+
+#include "task_runner.hh"
+
+#include <utility>
+
+template<typename R>
+void post_and_reply(TaskRunner* callback_runner,
+ std::function<R()> callback,
+ std::shared_ptr<TaskRunner> reply_runner,
+ std::function<void(R)> reply) {
+ callback_runner->post([callback, reply, reply_runner] () {
+ auto r = callback();
+ reply_runner->post(std::bind(std::move(reply), std::move(r)));
+ });
+}
+
+#endif // TASK_RUNNER_REPLY_HH