Skip to content

Commit

Permalink
Back out "Make async_tm and async_eb HandlerCallback param a shared_ptr"
Browse files Browse the repository at this point in the history
Summary:
Original commit changeset: 4feec3b1b393

Original Phabricator Diff: D55506070

Reviewed By: mogeb, sumit-g

Differential Revision: D55812267

fbshipit-source-id: 21037f6997e426b6ec5b7c90f7d7ce8b11be4e80
  • Loading branch information
Joe Hirschfeld authored and facebook-github-bot committed Apr 5, 2024
1 parent d6eab85 commit 3a96990
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 89 deletions.
2 changes: 1 addition & 1 deletion mcrouter/ServerOnRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ServerOnRequest {

template <class Request>
void onRequestThrift(
std::shared_ptr<apache::thrift::HandlerCallback<
std::unique_ptr<apache::thrift::HandlerCallback<
typename Request::reply_type>>&& callback,
Request&& req) {
if (HasKeyTrait<Request>::value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ class HelloGoodbyeServerOnRequestThrift : public thrift::HelloGoodbyeSvIf {
std::shared_ptr<ServerOnRequest>> serverOnRequestMap)
: serverOnRequestMap_(std::move(serverOnRequestMap)) {}
void async_eb_goodbye(
std::shared_ptr<apache::thrift::HandlerCallback<hellogoodbye::GoodbyeReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<hellogoodbye::GoodbyeReply>> callback,
const hellogoodbye::GoodbyeRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_hello(
std::shared_ptr<apache::thrift::HandlerCallback<hellogoodbye::HelloReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<hellogoodbye::HelloReply>> callback,
const hellogoodbye::HelloRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_mcVersion(
std::shared_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
const facebook::memcache::McVersionRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
Expand Down Expand Up @@ -70,7 +70,7 @@ class HelloGoodbyeServerOnRequestThrift : public thrift::HelloGoodbyeSvIf {
template <class Request>
void onRequestThriftHelper(
const Request& request,
std::shared_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
std::unique_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
callback) {
getServerOnRequest(callback->getEventBase())
->onRequestThrift(
Expand Down
10 changes: 6 additions & 4 deletions mcrouter/lib/carbon/example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class ThriftHandler : virtual public hellogoodbye::thrift::HelloGoodbyeSvIf {
virtual ~ThriftHandler() = default;

void async_eb_hello(
apache::thrift::HandlerCallback<hellogoodbye::HelloReply>::Ptr callback,
std::unique_ptr<apache::thrift::HandlerCallback<hellogoodbye::HelloReply>>
callback,
const hellogoodbye::HelloRequest& request) override {
LOG(INFO) << "Hello! Thrift server " << reinterpret_cast<uintptr_t>(this)
<< " got key " << request.key_ref()->fullKey().str();
Expand Down Expand Up @@ -90,7 +91,8 @@ class ThriftHandler : virtual public hellogoodbye::thrift::HelloGoodbyeSvIf {
}

void async_eb_goodbye(
apache::thrift::HandlerCallback<hellogoodbye::GoodbyeReply>::Ptr callback,
std::unique_ptr<
apache::thrift::HandlerCallback<hellogoodbye::GoodbyeReply>> callback,
const hellogoodbye::GoodbyeRequest& request) override {
LOG(INFO) << "Good bye! Thrift server " << reinterpret_cast<uintptr_t>(this)
<< " got key " << request.key_ref()->fullKey().str();
Expand All @@ -99,8 +101,8 @@ class ThriftHandler : virtual public hellogoodbye::thrift::HelloGoodbyeSvIf {
}

void async_eb_mcVersion(
apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>::Ptr
callback,
std::unique_ptr<apache::thrift::HandlerCallback<
facebook::memcache::McVersionReply>> callback,
const facebook::memcache::McVersionRequest& /* request */) override {
callback->result(McVersionReply(carbon::Result::OK));
}
Expand Down
6 changes: 3 additions & 3 deletions mcrouter/lib/carbon/test/gen/AServerOnRequestThrift.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class AServerOnRequestThrift : public thrift::ASvIf {
std::shared_ptr<ServerOnRequest>> serverOnRequestMap)
: serverOnRequestMap_(std::move(serverOnRequestMap)) {}
void async_eb_testA(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::A::TestAReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::A::TestAReply>> callback,
const carbon::test::A::TestARequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_mcVersion(
std::shared_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
const facebook::memcache::McVersionRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
Expand Down Expand Up @@ -66,7 +66,7 @@ class AServerOnRequestThrift : public thrift::ASvIf {
template <class Request>
void onRequestThriftHelper(
const Request& request,
std::shared_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
std::unique_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
callback) {
getServerOnRequest(callback->getEventBase())
->onRequestThrift(
Expand Down
6 changes: 3 additions & 3 deletions mcrouter/lib/carbon/test/gen/BServerOnRequestThrift.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class BServerOnRequestThrift : public thrift::BSvIf {
std::shared_ptr<ServerOnRequest>> serverOnRequestMap)
: serverOnRequestMap_(std::move(serverOnRequestMap)) {}
void async_eb_testB(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::B::TestBReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::B::TestBReply>> callback,
const carbon::test::B::TestBRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_mcVersion(
std::shared_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
const facebook::memcache::McVersionRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
Expand Down Expand Up @@ -66,7 +66,7 @@ class BServerOnRequestThrift : public thrift::BSvIf {
template <class Request>
void onRequestThriftHelper(
const Request& request,
std::shared_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
std::unique_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
callback) {
getServerOnRequest(callback->getEventBase())
->onRequestThrift(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ class CarbonTestServerOnRequestThrift : public thrift::CarbonTestSvIf {
std::shared_ptr<ServerOnRequest>> serverOnRequestMap)
: serverOnRequestMap_(std::move(serverOnRequestMap)) {}
void async_eb_test(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::TestReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::TestReply>> callback,
const carbon::test::TestRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_testStringKey(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::TestReplyStringKey>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::TestReplyStringKey>> callback,
const carbon::test::TestRequestStringKey& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_eb_mcVersion(
std::shared_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
const facebook::memcache::McVersionRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
Expand Down Expand Up @@ -71,7 +71,7 @@ class CarbonTestServerOnRequestThrift : public thrift::CarbonTestSvIf {
template <class Request>
void onRequestThriftHelper(
const Request& request,
std::shared_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
std::unique_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
callback) {
getServerOnRequest(callback->getEventBase())
->onRequestThrift(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ class CarbonThriftTestServerOnRequestThrift : public thrift::CarbonThriftTestSvI
std::shared_ptr<ServerOnRequest>> serverOnRequestMap)
: serverOnRequestMap_(std::move(serverOnRequestMap)) {}
void async_tm_customRequest(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::CustomReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::CustomReply>> callback,
const class carbon::test::CustomRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_tm_thrift_test(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::DummyThriftReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::DummyThriftReply>> callback,
const class carbon::test::DummyThriftRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_tm_test(
std::shared_ptr<apache::thrift::HandlerCallback<carbon::test::ThriftTestReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<carbon::test::ThriftTestReply>> callback,
const class carbon::test::ThriftTestRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
}
void async_tm_mcVersion(
std::shared_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
std::unique_ptr<apache::thrift::HandlerCallback<facebook::memcache::McVersionReply>> callback,
const class facebook::memcache::McVersionRequest& request) override final {
onRequestThriftHelper<std::remove_reference_t<decltype(request)>>(
request, std::move(callback));
Expand Down Expand Up @@ -77,7 +77,7 @@ class CarbonThriftTestServerOnRequestThrift : public thrift::CarbonThriftTestSvI
template <class Request>
void onRequestThriftHelper(
const Request& request,
std::shared_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
std::unique_ptr<apache::thrift::HandlerCallback<typename Request::reply_type>>
callback) {
getServerOnRequest(callback->getEventBase())
->onRequestThrift(
Expand Down
4 changes: 2 additions & 2 deletions mcrouter/lib/network/McThriftContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace memcache {
template <class Reply>
class McThriftContext {
public:
McThriftContext(typename apache::thrift::HandlerCallback<Reply>::Ptr ctx)
McThriftContext(std::unique_ptr<apache::thrift::HandlerCallback<Reply>> ctx)
: underlying_(std::move(ctx)) {}

static void
Expand Down Expand Up @@ -79,7 +79,7 @@ class McThriftContext {
}

private:
typename apache::thrift::HandlerCallback<Reply>::Ptr underlying_;
std::unique_ptr<apache::thrift::HandlerCallback<Reply>> underlying_;
};

} // namespace memcache
Expand Down
Loading

0 comments on commit 3a96990

Please sign in to comment.