future:then()/then_wrapped() simplification and optimization
future:then()/then_wrapped() simplification and optimization

Since commit f11c08c0e42986550b4f1345eb780, futurize<>::apply()
already catches exceptions and converts them into an exceptional future,
so the try/catch attempts in then<> (the basis for both then() and
then_wrapped()) were "supposed" to be redundant and should not actually
have caught anything.

But while for then_wrap() they indeed didn't catch anything, for then(),
it turns out they did! When then() sees an exceptional future, it is
supposed to just pass the exception along (without running the lambda).
But in the existing code it actually did something more convoluted:
it called get(), which *throws* the exception stored in the future, and
then catches this exception, and converts it back to an exception pointer.
All of this is of course inefficient, and bloats our code and compile time.

This convoluted code was created by trying to create a common then<>
template which both then() and then_wrapped() built on. But the "param"
template argument was not powerful enough, and resulted in the unnecessary
exception conversions and the unnecessary try/catches. So this patch
splits the code of then() and then_wrapped(), and makes each of them
do exactly the minimum it needs to do, without unneeded try/catch and
without rethrowing an exception pointer that can simply be moved.

The downside of this patch is that a few lines of code are now duplicated
between then() and then_wrapped(). I think this is a small price to pay
for getting them right. It's also easier to understand these stand-alone
functions than a heirarchy of templates and weird lambdas.

Signed-off-by: Nadav Har'El <625169824b719df98706d88646d0aae6f368ae4d@cloudius-systems.com>

joerg84/seastar,linearregression/seastar,cloudius-systems/seastar,flashbuckets/seastar,hongliangzhao/seastar,bowlofstew/seastar,stamhe/seastar,tempbottle/seastar,dwdm/seastar,koolhazz/seastar,leejir/seastar,avikivity/seastar,hongliangzhao/seastar,bowlofstew/seastar,printedheart/seastar,hongliangzhao/seastar,koolhazz/seastar,syuu1228/seastar,dwdm/seastar,cloudius-systems/seastar,scylladb/seastar,xtao/seastar,avikivity/seastar,flashbuckets/seastar,linearregression/seastar,joerg84/seastar,wildinto/seastar,kjniemi/seastar,avikivity/seastar,scylladb/seastar,anzihenry/seastar,printedheart/seastar,jonathanleang/seastar,wildinto/seastar,stamhe/seastar,norcimo5/seastar,leejir/seastar,mixja/seastar,anzihenry/seastar,leejir/seastar,scylladb/scylla-seastar,tempbottle/seastar,bowlofstew/seastar,kjniemi/seastar,dreamsxin/seastar,sjperkins/seastar,sjperkins/seastar,xtao/seastar,jonathanleang/seastar,wildinto/seastar,shyamalschandra/seastar,scylladb/scylla-seastar,jonathanleang/seastar,acbellini/seastar,dwdm/seastar,shyamalschandra/seastar,scylladb/seastar,dreamsxin/seastar,tempbottle/seastar,scylladb/scylla-seastar,koolhazz/seastar,syuu1228/seastar,anzihenry/seastar,sjperkins/seastar,kjniemi/seastar,chunshengster/seastar,dreamsxin/seastar,stamhe/seastar,shyamalschandra/seastar,chunshengster/seastar,printedheart/seastar,cloudius-systems/seastar,acbellini/seastar,xtao/seastar,norcimo5/seastar,chunshengster/seastar,linearregression/seastar,acbellini/seastar,syuu1228/seastar,norcimo5/seastar,mixja/seastar,flashbuckets/seastar,joerg84/seastar,mixja/seastar