mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
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.
This commit is contained in:
@@ -65,6 +65,18 @@ void complete(future<T...>& fut,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void complete(future<foreign_ptr<lw_shared_ptr<T>>>& fut,
|
||||
const tcxx::function<void (const T&)>& cob,
|
||||
const tcxx::function<void (::apache::thrift::TDelayedException* _throw)>& 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<database>& _db;
|
||||
keyspace* _ks = nullptr; // FIXME: reference counting for in-use detection?
|
||||
|
||||
Reference in New Issue
Block a user