blob: 1ca65a0249dc431831244040d13d0d5c78a5c235 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
|