/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/interactions/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #include "thrift/compiler/test/fixtures/interactions/gen-cpp2/InteractWithShared.h" #include "thrift/compiler/test/fixtures/interactions/gen-cpp2/InteractWithShared.tcc" #include "thrift/compiler/test/fixtures/interactions/gen-cpp2/module_metadata.h" #include std::unique_ptr apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::getProcessor() { return std::make_unique<::cpp2::InteractWithSharedAsyncProcessor>(this); } apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::CreateMethodMetadataResult apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::createMethodMetadata() { return ::apache::thrift::detail::ap::createMethodMetadataMap<::cpp2::InteractWithSharedAsyncProcessor>(getServiceRequestInfoMap().value().get()); } std::optional> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::getServiceRequestInfoMap() const { return __fbthrift_serviceInfoHolder.requestInfoMap(); } ::cpp2::InteractWithSharedServiceInfoHolder apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::__fbthrift_serviceInfoHolder; void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& /*_return*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("do_some_similar_things"); } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::sync_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return) { return do_some_similar_things(_return); } folly::SemiFuture> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::semifuture_do_some_similar_things() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); auto ret = std::make_unique<::thrift::shared_interactions::DoSomethingResult>(); sync_do_some_similar_things(*ret); return folly::makeSemiFuture(std::move(ret)); } folly::Future> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::future_do_some_similar_things() { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_do_some_similar_things(), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::co_do_some_similar_things() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::co_do_some_similar_things(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_do_some_similar_things(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::async_tm_do_some_similar_things(apache::thrift::HandlerCallbackPtr> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_do_some_similar_things.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_do_some_similar_things(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_do_some_similar_things.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::Future: { auto fut = future_do_some_similar_things(); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_do_some_similar_things(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_do_some_similar_things(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_do_some_similar_things(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { ::thrift::shared_interactions::DoSomethingResult _return; sync_do_some_similar_things(_return); callback->result(std::move(_return)); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } std::unique_ptr::MyInteractionIf> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::createMyInteraction() { apache::thrift::detail::si::throw_app_exn_unimplemented("createMyInteraction"); } std::unique_ptr::SharedInteractionIf> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::createshared.SharedInteraction() { apache::thrift::detail::si::throw_app_exn_unimplemented("createshared.SharedInteraction"); } ::std::int32_t apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::frobnicate() { apache::thrift::detail::si::throw_app_exn_unimplemented("frobnicate"); } ::std::int32_t apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::sync_frobnicate() { return frobnicate(); } folly::SemiFuture<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::semifuture_frobnicate() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_frobnicate.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); return sync_frobnicate(); } #if FOLLY_HAS_COROUTINES folly::coro::Task<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_frobnicate() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_frobnicate.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_frobnicate(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_frobnicate.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_frobnicate(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::async_tm_frobnicate(apache::thrift::HandlerCallbackPtr<::std::int32_t> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_frobnicate.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_frobnicate.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_frobnicate(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_frobnicate.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_frobnicate(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_frobnicate(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_frobnicate(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { callback->result(sync_frobnicate()); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::ping() { apache::thrift::detail::si::throw_app_exn_unimplemented("ping"); } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::sync_ping() { return ping(); } folly::SemiFuture apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::semifuture_ping() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_ping.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_ping(); return folly::makeSemiFuture(); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_ping() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_ping.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_ping(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_ping.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_ping(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::async_tm_ping(apache::thrift::HandlerCallbackBase::Ptr callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_ping.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_ping.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_ping(params); apache::thrift::detail::si::async_tm_coro_oneway(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_ping.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_ping(); apache::thrift::detail::si::async_tm_semifuture_oneway(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_ping(params); apache::thrift::detail::si::async_tm_coro_oneway(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_ping(); apache::thrift::detail::si::async_tm_coro_oneway(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { sync_ping(); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } ::apache::thrift::ServerStream apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::truthify() { apache::thrift::detail::si::throw_app_exn_unimplemented("truthify"); } ::apache::thrift::ServerStream apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::sync_truthify() { return truthify(); } folly::SemiFuture<::apache::thrift::ServerStream> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::semifuture_truthify() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_truthify.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); return sync_truthify(); } #if FOLLY_HAS_COROUTINES folly::coro::Task<::apache::thrift::ServerStream> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_truthify() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_truthify.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task<::apache::thrift::ServerStream> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_truthify(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_truthify.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_truthify(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::async_tm_truthify(apache::thrift::HandlerCallbackPtr<::apache::thrift::ServerStream> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_truthify.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_truthify.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_truthify(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_truthify.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_truthify(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_truthify(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_truthify(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { callback->result(sync_truthify()); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } ::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::encode() { apache::thrift::detail::si::throw_app_exn_unimplemented("encode"); } ::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::sync_encode() { return encode(); } folly::SemiFuture<::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string>> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::semifuture_encode() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_encode.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); return sync_encode(); } #if FOLLY_HAS_COROUTINES folly::coro::Task<::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string>> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_encode() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_encode.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task<::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string>> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::co_encode(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_encode.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_encode(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::MyInteractionIf::async_tm_encode(apache::thrift::HandlerCallbackPtr<::apache::thrift::ResponseAndSinkConsumer<::std::set<::std::int32_t>, ::std::string, ::std::string>> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_encode.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_encode.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_encode(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_encode.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_encode(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_encode(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_encode(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { callback->result(sync_encode()); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } ::std::int32_t apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::init() { apache::thrift::detail::si::throw_app_exn_unimplemented("init"); } ::std::int32_t apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::sync_init() { return init(); } folly::SemiFuture<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::semifuture_init() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_init.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); return sync_init(); } #if FOLLY_HAS_COROUTINES folly::coro::Task<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_init() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_init.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task<::std::int32_t> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_init(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_init.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_init(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::async_tm_init(apache::thrift::HandlerCallbackPtr<::std::int32_t> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_init.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_init.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_init(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_init.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_init(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_init(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_init(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { callback->result(sync_init()); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::do_something(::thrift::shared_interactions::DoSomethingResult& /*_return*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("do_something"); } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::sync_do_something(::thrift::shared_interactions::DoSomethingResult& _return) { return do_something(_return); } folly::SemiFuture> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::semifuture_do_something() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_do_something.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); auto ret = std::make_unique<::thrift::shared_interactions::DoSomethingResult>(); sync_do_something(*ret); return folly::makeSemiFuture(std::move(ret)); } #if FOLLY_HAS_COROUTINES folly::coro::Task> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_do_something() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_do_something.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task> apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_do_something(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_do_something.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_do_something(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::async_tm_do_something(apache::thrift::HandlerCallbackPtr> callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_do_something.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_do_something.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_do_something(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_do_something.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_do_something(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_do_something(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_do_something(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { ::thrift::shared_interactions::DoSomethingResult _return; sync_do_something(_return); callback->result(std::move(_return)); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::tear_down() { apache::thrift::detail::si::throw_app_exn_unimplemented("tear_down"); } void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::sync_tear_down() { return tear_down(); } folly::SemiFuture apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::semifuture_tear_down() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_tear_down.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_tear_down(); return folly::makeSemiFuture(); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_tear_down() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_tear_down.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<>()); } folly::coro::Task apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::co_tear_down(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_tear_down.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_tear_down(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::cpp2::InteractWithShared>::SharedInteractionIf::async_tm_tear_down(apache::thrift::HandlerCallbackPtr callback) { // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_tear_down.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_tear_down.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_tear_down(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_tear_down.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_tear_down(); apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_tear_down(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_tear_down(); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { sync_tear_down(); callback->done(); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie() = std::move(ex).restoreArgs<>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } namespace cpp2 { void InteractWithSharedSvNull::do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& /*_return*/) { } const char* InteractWithSharedAsyncProcessor::getServiceName() { return "InteractWithShared"; } void InteractWithSharedAsyncProcessor::getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) { ::apache::thrift::detail::md::ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::InteractWithShared>>::gen(response); } void InteractWithSharedAsyncProcessor::processSerializedCompressedRequestWithMetadata(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) { apache::thrift::detail::ap::process(this, iface_, std::move(req), std::move(serializedRequest), methodMetadata, protType, context, eb, tm); } void InteractWithSharedAsyncProcessor::executeRequest(apache::thrift::ServerRequest&& request, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata) { apache::thrift::detail::ap::execute(this, std::move(request), apache::thrift::detail::ServerRequestHelper::protocol(request), methodMetadata); } const InteractWithSharedAsyncProcessor::ProcessMap& InteractWithSharedAsyncProcessor::getOwnProcessMap() { return kOwnProcessMap_; } const InteractWithSharedAsyncProcessor::ProcessMap InteractWithSharedAsyncProcessor::kOwnProcessMap_ { {"do_some_similar_things", {&InteractWithSharedAsyncProcessor::setUpAndProcess_do_some_similar_things, &InteractWithSharedAsyncProcessor::setUpAndProcess_do_some_similar_things, &InteractWithSharedAsyncProcessor::executeRequest_do_some_similar_things, &InteractWithSharedAsyncProcessor::executeRequest_do_some_similar_things}}, {"MyInteraction.frobnicate", {&InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_frobnicate, &InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_frobnicate, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_frobnicate, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_frobnicate}}, {"MyInteraction.ping", {&InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_ping, &InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_ping, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_ping, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_ping}}, {"MyInteraction.truthify", {&InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_truthify, &InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_truthify, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_truthify, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_truthify}}, {"MyInteraction.encode", {&InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_encode, &InteractWithSharedAsyncProcessor::setUpAndProcess_MyInteraction_encode, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_encode, &InteractWithSharedAsyncProcessor::executeRequest_MyInteraction_encode}}, {"SharedInteraction.init", {&InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_init, &InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_init, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_init, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_init}}, {"SharedInteraction.do_something", {&InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_do_something, &InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_do_something, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_do_something, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_do_something}}, {"SharedInteraction.tear_down", {&InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_tear_down, &InteractWithSharedAsyncProcessor::setUpAndProcess_SharedInteraction_tear_down, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_tear_down, &InteractWithSharedAsyncProcessor::executeRequest_SharedInteraction_tear_down}}, }; apache::thrift::ServiceRequestInfoMap const& InteractWithSharedServiceInfoHolder::requestInfoMap() const { static folly::Indestructible requestInfoMap{staticRequestInfoMap()}; return *requestInfoMap; } apache::thrift::ServiceRequestInfoMap InteractWithSharedServiceInfoHolder::staticRequestInfoMap() { apache::thrift::ServiceRequestInfoMap requestInfoMap = { {"do_some_similar_things", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "InteractWithShared.do_some_similar_things", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"MyInteraction.frobnicate", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "InteractWithShared.MyInteraction.frobnicate", "MyInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"MyInteraction.ping", { false, apache::thrift::RpcKind::SINGLE_REQUEST_NO_RESPONSE, "InteractWithShared.MyInteraction.ping", "MyInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"MyInteraction.truthify", { false, apache::thrift::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, "InteractWithShared.MyInteraction.truthify", "MyInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"MyInteraction.encode", { false, apache::thrift::RpcKind::SINK, "InteractWithShared.MyInteraction.encode", "MyInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"SharedInteraction.init", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "InteractWithShared.SharedInteraction.init", "SharedInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"SharedInteraction.do_something", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "InteractWithShared.SharedInteraction.do_something", "SharedInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, {"SharedInteraction.tear_down", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "InteractWithShared.SharedInteraction.tear_down", "SharedInteraction", apache::thrift::concurrency::NORMAL, std::nullopt}}, }; return requestInfoMap; } const InteractWithSharedAsyncProcessor::InteractionConstructorMap& InteractWithSharedAsyncProcessor::getInteractionConstructorMap() { return interactionConstructorMap_; } const InteractWithSharedAsyncProcessor::InteractionConstructorMap InteractWithSharedAsyncProcessor::interactionConstructorMap_ { {"MyInteraction", &InteractWithSharedAsyncProcessor::createMyInteraction}, {"SharedInteraction", &InteractWithSharedAsyncProcessor::createshared.SharedInteraction}, }; std::unique_ptr InteractWithSharedAsyncProcessor::createInteractionImpl(const std::string& name) { auto fn = getInteractionConstructorMap().at(name); return (this->*fn)(); }} // namespace cpp2