/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/basic/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #include "thrift/compiler/test/fixtures/basic/gen-cpp2/MyService.h" #include "thrift/compiler/test/fixtures/basic/gen-cpp2/MyService.tcc" #include "thrift/compiler/test/fixtures/basic/gen-cpp2/module_metadata.h" #include std::unique_ptr apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::getProcessor() { return std::make_unique<::test::fixtures::basic::MyServiceAsyncProcessor>(this); } apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::CreateMethodMetadataResult apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::createMethodMetadata() { return ::apache::thrift::detail::ap::createMethodMetadataMap<::test::fixtures::basic::MyServiceAsyncProcessor>(getServiceRequestInfoMap().value().get()); } std::optional> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::getServiceRequestInfoMap() const { return __fbthrift_serviceInfoHolder.requestInfoMap(); } ::test::fixtures::basic::MyServiceServiceInfoHolder apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::__fbthrift_serviceInfoHolder; void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::ping() { apache::thrift::detail::si::throw_app_exn_unimplemented("ping"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_ping() { return ping(); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::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(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_ping() { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_ping.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_ping(), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_ping() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_ping.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<::test::fixtures::basic::MyService>::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<::test::fixtures::basic::MyService>::async_tm_ping(std::unique_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(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_ping.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_ping(); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_ping(); 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_ping(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_ping(); 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_ping(); 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()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::getRandomData(::std::string& /*_return*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("getRandomData"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_getRandomData(::std::string& _return) { return getRandomData(_return); } folly::SemiFuture> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_getRandomData() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_getRandomData.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); auto ret = std::make_unique<::std::string>(); sync_getRandomData(*ret); return folly::makeSemiFuture(std::move(ret)); } folly::Future> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_getRandomData() { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_getRandomData.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_getRandomData(), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_getRandomData() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_getRandomData.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<::test::fixtures::basic::MyService>::co_getRandomData(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_getRandomData.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_getRandomData(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_getRandomData(std::unique_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_getRandomData.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_getRandomData.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_getRandomData(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_getRandomData.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_getRandomData(); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_getRandomData(); 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_getRandomData(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_getRandomData(); 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: { ::std::string _return; sync_getRandomData(_return); callback->result(_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<::test::fixtures::basic::MyService>::sink(::std::int64_t /*sink*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("sink"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_sink(::std::int64_t p_sink) { return sink(p_sink); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_sink(::std::int64_t p_sink) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_sink.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_sink(p_sink); return folly::makeSemiFuture(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_sink(::std::int64_t p_sink) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_sink.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_sink(p_sink), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_sink(::std::int64_t p_sink) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_sink.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*sink*/>(p_sink)); } folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_sink(apache::thrift::RequestParams /* params */, ::std::int64_t p_sink) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_sink.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_sink(p_sink); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_sink(std::unique_ptr> callback, ::std::int64_t p_sink) { // 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_sink.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_sink.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_sink(params, p_sink); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_sink.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_sink(p_sink); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_sink(p_sink); 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_sink(params, p_sink); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_sink(p_sink); 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_sink(p_sink); callback->done(); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_sink) = std::move(ex).restoreArgs<::std::int64_t /*sink*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::putDataById(::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("putDataById"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_putDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { return putDataById(p_id, std::move(p_data)); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_putDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_putDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_putDataById(p_id, std::move(p_data)); return folly::makeSemiFuture(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_putDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_putDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_putDataById(p_id, std::move(p_data)), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_putDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_putDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/>(p_id, std::move(p_data))); } folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_putDataById(apache::thrift::RequestParams /* params */, ::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_putDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_putDataById(p_id, std::move(p_data)); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_putDataById(std::unique_ptr> callback, ::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { // 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_putDataById.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_putDataById.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_putDataById(params, p_id, std::move(p_data)); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_putDataById.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_putDataById(p_id, std::move(p_data)); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_putDataById(p_id, std::move(p_data)); 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_putDataById(params, p_id, std::move(p_data)); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_putDataById(p_id, std::move(p_data)); 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_putDataById(p_id, std::move(p_data)); callback->done(); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_id, p_data) = std::move(ex).restoreArgs<::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } bool apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::hasDataById(::std::int64_t /*id*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("hasDataById"); } bool apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_hasDataById(::std::int64_t p_id) { return hasDataById(p_id); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_hasDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_hasDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); return sync_hasDataById(p_id); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_hasDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_hasDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_hasDataById(p_id), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_hasDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_hasDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*id*/>(p_id)); } folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_hasDataById(apache::thrift::RequestParams /* params */, ::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_hasDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_hasDataById(p_id); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_hasDataById(std::unique_ptr> callback, ::std::int64_t p_id) { // 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_hasDataById.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_hasDataById.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_hasDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_hasDataById.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_hasDataById(p_id); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_hasDataById(p_id); 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_hasDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_hasDataById(p_id); 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_hasDataById(p_id)); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_id) = std::move(ex).restoreArgs<::std::int64_t /*id*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::getDataById(::std::string& /*_return*/, ::std::int64_t /*id*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("getDataById"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_getDataById(::std::string& _return, ::std::int64_t p_id) { return getDataById(_return, p_id); } folly::SemiFuture> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_getDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_getDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); auto ret = std::make_unique<::std::string>(); sync_getDataById(*ret, p_id); return folly::makeSemiFuture(std::move(ret)); } folly::Future> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_getDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_getDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_getDataById(p_id), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_getDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_getDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*id*/>(p_id)); } folly::coro::Task> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_getDataById(apache::thrift::RequestParams /* params */, ::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_getDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_getDataById(p_id); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_getDataById(std::unique_ptr>> callback, ::std::int64_t p_id) { // 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_getDataById.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_getDataById.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_getDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_getDataById.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_getDataById(p_id); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_getDataById(p_id); 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_getDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_getDataById(p_id); 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: { ::std::string _return; sync_getDataById(_return, p_id); callback->result(_return); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_id) = std::move(ex).restoreArgs<::std::int64_t /*id*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::deleteDataById(::std::int64_t /*id*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("deleteDataById"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_deleteDataById(::std::int64_t p_id) { return deleteDataById(p_id); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_deleteDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_deleteDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_deleteDataById(p_id); return folly::makeSemiFuture(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_deleteDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_deleteDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_deleteDataById(p_id), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_deleteDataById(::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_deleteDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*id*/>(p_id)); } folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_deleteDataById(apache::thrift::RequestParams /* params */, ::std::int64_t p_id) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_deleteDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_deleteDataById(p_id); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_deleteDataById(std::unique_ptr> callback, ::std::int64_t p_id) { // 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_deleteDataById.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_deleteDataById.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_deleteDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_deleteDataById.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_deleteDataById(p_id); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_deleteDataById(p_id); 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_deleteDataById(params, p_id); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_deleteDataById(p_id); 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_deleteDataById(p_id); callback->done(); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_id) = std::move(ex).restoreArgs<::std::int64_t /*id*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::lobDataById(::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("lobDataById"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_lobDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { return lobDataById(p_id, std::move(p_data)); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_lobDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_lobDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_lobDataById(p_id, std::move(p_data)); return folly::makeSemiFuture(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_lobDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_lobDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_lobDataById(p_id, std::move(p_data)), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_lobDataById(::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_lobDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/>(p_id, std::move(p_data))); } folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_lobDataById(apache::thrift::RequestParams /* params */, ::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_lobDataById.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_lobDataById(p_id, std::move(p_data)); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_lobDataById(std::unique_ptr callback, ::std::int64_t p_id, std::unique_ptr<::std::string> p_data) { // 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_lobDataById.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_lobDataById.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_lobDataById(params, p_id, std::move(p_data)); apache::thrift::detail::si::async_tm_coro_oneway(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_lobDataById.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_lobDataById(p_id, std::move(p_data)); apache::thrift::detail::si::async_tm_future_oneway(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_lobDataById(p_id, std::move(p_data)); 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_lobDataById(params, p_id, std::move(p_data)); 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_lobDataById(p_id, std::move(p_data)); 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_lobDataById(p_id, std::move(p_data)); return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod& ex) { std::tie(p_id, p_data) = std::move(ex).restoreArgs<::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/>(); goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::invalid_return_for_hack(::std::set& /*_return*/) { apache::thrift::detail::si::throw_app_exn_unimplemented("invalid_return_for_hack"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_invalid_return_for_hack(::std::set& _return) { return invalid_return_for_hack(_return); } folly::SemiFuture>> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_invalid_return_for_hack() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_invalid_return_for_hack.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); auto ret = std::make_unique<::std::set>(); sync_invalid_return_for_hack(*ret); return folly::makeSemiFuture(std::move(ret)); } folly::Future>> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_invalid_return_for_hack() { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_invalid_return_for_hack.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_invalid_return_for_hack(), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task>> apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_invalid_return_for_hack() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_invalid_return_for_hack.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<::test::fixtures::basic::MyService>::co_invalid_return_for_hack(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_invalid_return_for_hack.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_invalid_return_for_hack(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_invalid_return_for_hack(std::unique_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_invalid_return_for_hack.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_invalid_return_for_hack.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_invalid_return_for_hack(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_invalid_return_for_hack.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_invalid_return_for_hack(); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_invalid_return_for_hack(); 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_invalid_return_for_hack(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_invalid_return_for_hack(); 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: { ::std::set _return; sync_invalid_return_for_hack(_return); callback->result(_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<::test::fixtures::basic::MyService>::rpc_skipped_codegen() { apache::thrift::detail::si::throw_app_exn_unimplemented("rpc_skipped_codegen"); } void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::sync_rpc_skipped_codegen() { return rpc_skipped_codegen(); } folly::SemiFuture apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::semifuture_rpc_skipped_codegen() { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_rpc_skipped_codegen.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); sync_rpc_skipped_codegen(); return folly::makeSemiFuture(); } folly::Future apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::future_rpc_skipped_codegen() { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_rpc_skipped_codegen.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_rpc_skipped_codegen(), getInternalKeepAlive()); } #if FOLLY_HAS_COROUTINES folly::coro::Task apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::co_rpc_skipped_codegen() { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_rpc_skipped_codegen.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<::test::fixtures::basic::MyService>::co_rpc_skipped_codegen(apache::thrift::RequestParams /* params */) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_rpc_skipped_codegen.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_rpc_skipped_codegen(); } #endif // FOLLY_HAS_COROUTINES void apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>::async_tm_rpc_skipped_codegen(std::unique_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_rpc_skipped_codegen.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_rpc_skipped_codegen.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_rpc_skipped_codegen(params); apache::thrift::detail::si::async_tm_coro(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES __fbthrift_invocation_rpc_skipped_codegen.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_rpc_skipped_codegen(); apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut)); return; } case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_rpc_skipped_codegen(); 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_rpc_skipped_codegen(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_rpc_skipped_codegen(); 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_rpc_skipped_codegen(); 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 test::fixtures::basic { void MyServiceSvNull::ping() { return; } void MyServiceSvNull::getRandomData(::std::string& /*_return*/) { } void MyServiceSvNull::sink(::std::int64_t /*sink*/) { return; } void MyServiceSvNull::putDataById(::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/) { return; } bool MyServiceSvNull::hasDataById(::std::int64_t /*id*/) { return 0; } void MyServiceSvNull::getDataById(::std::string& /*_return*/, ::std::int64_t /*id*/) { } void MyServiceSvNull::deleteDataById(::std::int64_t /*id*/) { return; } void MyServiceSvNull::lobDataById(::std::int64_t /*id*/, std::unique_ptr<::std::string> /*data*/) { return; } void MyServiceSvNull::invalid_return_for_hack(::std::set& /*_return*/) { } void MyServiceSvNull::rpc_skipped_codegen() { return; } const char* MyServiceAsyncProcessor::getServiceName() { return "MyService"; } void MyServiceAsyncProcessor::getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) { ::apache::thrift::detail::md::ServiceMetadata<::apache::thrift::ServiceHandler<::test::fixtures::basic::MyService>>::gen(response); } void MyServiceAsyncProcessor::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 MyServiceAsyncProcessor::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 MyServiceAsyncProcessor::ProcessMap& MyServiceAsyncProcessor::getOwnProcessMap() { return kOwnProcessMap_; } const MyServiceAsyncProcessor::ProcessMap MyServiceAsyncProcessor::kOwnProcessMap_ { {"ping", {&MyServiceAsyncProcessor::setUpAndProcess_ping, &MyServiceAsyncProcessor::setUpAndProcess_ping, &MyServiceAsyncProcessor::executeRequest_ping, &MyServiceAsyncProcessor::executeRequest_ping}}, {"getRandomData", {&MyServiceAsyncProcessor::setUpAndProcess_getRandomData, &MyServiceAsyncProcessor::setUpAndProcess_getRandomData, &MyServiceAsyncProcessor::executeRequest_getRandomData, &MyServiceAsyncProcessor::executeRequest_getRandomData}}, {"sink", {&MyServiceAsyncProcessor::setUpAndProcess_sink, &MyServiceAsyncProcessor::setUpAndProcess_sink, &MyServiceAsyncProcessor::executeRequest_sink, &MyServiceAsyncProcessor::executeRequest_sink}}, {"putDataById", {&MyServiceAsyncProcessor::setUpAndProcess_putDataById, &MyServiceAsyncProcessor::setUpAndProcess_putDataById, &MyServiceAsyncProcessor::executeRequest_putDataById, &MyServiceAsyncProcessor::executeRequest_putDataById}}, {"hasDataById", {&MyServiceAsyncProcessor::setUpAndProcess_hasDataById, &MyServiceAsyncProcessor::setUpAndProcess_hasDataById, &MyServiceAsyncProcessor::executeRequest_hasDataById, &MyServiceAsyncProcessor::executeRequest_hasDataById}}, {"getDataById", {&MyServiceAsyncProcessor::setUpAndProcess_getDataById, &MyServiceAsyncProcessor::setUpAndProcess_getDataById, &MyServiceAsyncProcessor::executeRequest_getDataById, &MyServiceAsyncProcessor::executeRequest_getDataById}}, {"deleteDataById", {&MyServiceAsyncProcessor::setUpAndProcess_deleteDataById, &MyServiceAsyncProcessor::setUpAndProcess_deleteDataById, &MyServiceAsyncProcessor::executeRequest_deleteDataById, &MyServiceAsyncProcessor::executeRequest_deleteDataById}}, {"lobDataById", {&MyServiceAsyncProcessor::setUpAndProcess_lobDataById, &MyServiceAsyncProcessor::setUpAndProcess_lobDataById, &MyServiceAsyncProcessor::executeRequest_lobDataById, &MyServiceAsyncProcessor::executeRequest_lobDataById}}, {"invalid_return_for_hack", {&MyServiceAsyncProcessor::setUpAndProcess_invalid_return_for_hack, &MyServiceAsyncProcessor::setUpAndProcess_invalid_return_for_hack, &MyServiceAsyncProcessor::executeRequest_invalid_return_for_hack, &MyServiceAsyncProcessor::executeRequest_invalid_return_for_hack}}, {"rpc_skipped_codegen", {&MyServiceAsyncProcessor::setUpAndProcess_rpc_skipped_codegen, &MyServiceAsyncProcessor::setUpAndProcess_rpc_skipped_codegen, &MyServiceAsyncProcessor::executeRequest_rpc_skipped_codegen, &MyServiceAsyncProcessor::executeRequest_rpc_skipped_codegen}}, }; apache::thrift::ServiceRequestInfoMap const& MyServiceServiceInfoHolder::requestInfoMap() const { static folly::Indestructible requestInfoMap{staticRequestInfoMap()}; return *requestInfoMap; } apache::thrift::ServiceRequestInfoMap MyServiceServiceInfoHolder::staticRequestInfoMap() { apache::thrift::ServiceRequestInfoMap requestInfoMap = { {"ping", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.ping", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"getRandomData", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.getRandomData", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"sink", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.sink", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"putDataById", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.putDataById", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"hasDataById", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.hasDataById", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"getDataById", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.getDataById", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"deleteDataById", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.deleteDataById", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"lobDataById", { false, apache::thrift::RpcKind::SINGLE_REQUEST_NO_RESPONSE, "MyService.lobDataById", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"invalid_return_for_hack", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.invalid_return_for_hack", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, {"rpc_skipped_codegen", { false, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, "MyService.rpc_skipped_codegen", std::nullopt, apache::thrift::concurrency::NORMAL, std::nullopt}}, }; return requestInfoMap; } } // namespace test::fixtures::basic