From 78b77f9da89bc367226db346ea7ca0f3e609626f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 18 Jan 2018 06:01:49 -0800 Subject: [PATCH] ircd::ctx: Eliminate the shared_ptr in pool::async; minor cleanup. --- include/ircd/ctx/async.h | 2 +- include/ircd/ctx/pool.h | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/ircd/ctx/async.h b/include/ircd/ctx/async.h index 7f8c8404d..cd88c6167 100644 --- a/include/ircd/ctx/async.h +++ b/include/ircd/ctx/async.h @@ -38,7 +38,7 @@ namespace ircd::ctx future::type>>::type; template future_value async(F&& f, A&&... a); diff --git a/include/ircd/ctx/pool.h b/include/ircd/ctx/pool.h index ee6cbed54..9be9acaa5 100644 --- a/include/ircd/ctx/pool.h +++ b/include/ircd/ctx/pool.h @@ -90,18 +90,15 @@ ircd::ctx::pool::async(F&& f, std::bind(std::forward(f), std::forward(a)...) }; - auto p - { - std::make_shared>() - }; - - (*this)([p, func(std::move(func))] + promise p; + future ret{p}; + (*this)([p(std::move(p)), func(std::move(func))] () -> void { - p->set_value(func()); + p.set_value(func()); }); - return future(*p); + return ret; } template(f), std::forward(a)...) }; - auto p - { - std::make_shared>() - }; - - (*this)([p, func(std::move(func))] + promise p; + future ret{p}; + (*this)([p(std::move(p)), func(std::move(func))] () -> void { func(); - p->set_value(); + p.set_value(); }); - return future(*p); + return ret; }