0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

ircd::ctx: Eliminate the shared_ptr in pool::async; minor cleanup.

This commit is contained in:
Jason Volk 2018-01-18 06:01:49 -08:00
parent 90ea730a04
commit 78b77f9da8
2 changed files with 11 additions and 17 deletions

View file

@ -38,7 +38,7 @@ namespace ircd::ctx
future<typename std::result_of<F (A...)>::type>>::type;
template<size_t stack_size = DEFAULT_STACK_SIZE,
context::flags flags = (context::flags)0,
context::flags flags = context::flags(0),
class F,
class... A>
future_value<F, A...> async(F&& f, A&&... a);

View file

@ -90,18 +90,15 @@ ircd::ctx::pool::async(F&& f,
std::bind(std::forward<F>(f), std::forward<A>(a)...)
};
auto p
{
std::make_shared<promise<R>>()
};
(*this)([p, func(std::move(func))]
promise<R> p;
future<R> ret{p};
(*this)([p(std::move(p)), func(std::move(func))]
() -> void
{
p->set_value(func());
p.set_value(func());
});
return future<R>(*p);
return ret;
}
template<class F,
@ -117,17 +114,14 @@ ircd::ctx::pool::async(F&& f,
std::bind(std::forward<F>(f), std::forward<A>(a)...)
};
auto p
{
std::make_shared<promise<R>>()
};
(*this)([p, func(std::move(func))]
promise<R> p;
future<R> ret{p};
(*this)([p(std::move(p)), func(std::move(func))]
() -> void
{
func();
p->set_value();
p.set_value();
});
return future<R>(*p);
return ret;
}