From 0db67ff121d19969911ec761cc7ffe2a42f345ce Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 22 Feb 2015 17:50:09 +0200 Subject: [PATCH] thrift: add foreign_ptr<> variant to complete() Some calls will return complex types, so allow them to return a foreign_ptr<> to ensure cleanup will happen in the correct place. --- thrift/handler.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/thrift/handler.cc b/thrift/handler.cc index fa9ce8ae2e..6d20a544cf 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -65,6 +65,18 @@ void complete(future& fut, } } +template +void complete(future>>& fut, + const tcxx::function& cob, + const tcxx::function& exn_cob) { + try { + cob(*std::get<0>(fut.get())); + } catch (...) { + delayed_exception_wrapper dew(std::current_exception()); + exn_cob(&dew); + } +} + class CassandraAsyncHandler : public CassandraCobSvIf { distributed& _db; keyspace* _ks = nullptr; // FIXME: reference counting for in-use detection?