Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- std::future<std::decay_t<T>> make_ready_future( T&& t ) {
- std::promise<std::decay_t<T>> pr;
- auto r = pr.get_future();
- pr.set_value(std::forward<T>(t));
- return r;
- }
- template<class T>
- struct promise_pipe {
- std::future<T> out;
- std::function<void(T)> in;
- promise_pipe() {
- auto pr = std::make_shared<std::promise<T>>();
- out = pr->get_future();
- in = [pr](T t)mutable{
- if (pr) pr->set_value(std::forward<T>(t));
- pr = {};
- };
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement