summaryrefslogtreecommitdiff
path: root/src/task_runner_reply.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /src/task_runner_reply.hh
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in memroy.
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