Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / test / fixtures / basic / gen-cpp2 / FB303Service.cpp
blob07fc95332fef67ace6cdde7a0bb7ebf19a38f0b4
1 /**
2 * Autogenerated by Thrift for src/module.thrift
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated @nocommit
6 */
8 #include "thrift/compiler/test/fixtures/basic/gen-cpp2/FB303Service.h"
9 #include "thrift/compiler/test/fixtures/basic/gen-cpp2/FB303Service.tcc"
10 #include "thrift/compiler/test/fixtures/basic/gen-cpp2/module_metadata.h"
11 #include <thrift/lib/cpp2/gen/service_cpp.h>
13 std::unique_ptr<apache::thrift::AsyncProcessor> apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::getProcessor() {
14 return std::make_unique<::test::fixtures::basic::FB303ServiceAsyncProcessor>(this);
17 apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::CreateMethodMetadataResult apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::createMethodMetadata() {
18 return ::apache::thrift::detail::ap::createMethodMetadataMap<::test::fixtures::basic::FB303ServiceAsyncProcessor>(getServiceRequestInfoMap().value().get());
21 std::optional<std::reference_wrapper<apache::thrift::ServiceRequestInfoMap const>> apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::getServiceRequestInfoMap() const {
22 return __fbthrift_serviceInfoHolder.requestInfoMap();
25 ::test::fixtures::basic::FB303ServiceServiceInfoHolder apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::__fbthrift_serviceInfoHolder;
28 void apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::simple_rpc(::test::fixtures::basic::ReservedKeyword& /*_return*/, ::std::int32_t /*int_parameter*/) {
29 apache::thrift::detail::si::throw_app_exn_unimplemented("simple_rpc");
32 folly::SemiFuture<std::unique_ptr<::test::fixtures::basic::ReservedKeyword>> apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::semifuture_simple_rpc(::std::int32_t p_int_parameter) {
33 auto expected{apache::thrift::detail::si::InvocationType::SemiFuture};
34 __fbthrift_invocation_simple_rpc.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed);
35 auto ret = std::make_unique<::test::fixtures::basic::ReservedKeyword>();
36 simple_rpc(*ret, p_int_parameter);
37 return folly::makeSemiFuture(std::move(ret));
40 folly::Future<std::unique_ptr<::test::fixtures::basic::ReservedKeyword>> apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::future_simple_rpc(::std::int32_t p_int_parameter) {
41 auto expected{apache::thrift::detail::si::InvocationType::Future};
42 __fbthrift_invocation_simple_rpc.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed);
43 return apache::thrift::detail::si::future(semifuture_simple_rpc(p_int_parameter), getInternalKeepAlive());
46 void apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>::async_tm_simple_rpc(std::unique_ptr<apache::thrift::HandlerCallback<std::unique_ptr<::test::fixtures::basic::ReservedKeyword>>> callback, ::std::int32_t p_int_parameter) {
47 // It's possible the coroutine versions will delegate to a future-based
48 // version. If that happens, we need the RequestParams arguments to be
49 // available to the future through the thread-local backchannel, so we create
50 // a RAII object that sets up RequestParams and clears them on destruction.
51 apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get());
52 auto invocationType = __fbthrift_invocation_simple_rpc.load(std::memory_order_relaxed);
53 try {
54 switch (invocationType) {
55 case apache::thrift::detail::si::InvocationType::AsyncTm:
57 __fbthrift_invocation_simple_rpc.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed);
58 FOLLY_FALLTHROUGH;
60 case apache::thrift::detail::si::InvocationType::Future:
62 auto fut = future_simple_rpc(p_int_parameter);
63 apache::thrift::detail::si::async_tm_future(std::move(callback), std::move(fut));
64 return;
66 case apache::thrift::detail::si::InvocationType::SemiFuture:
68 auto fut = semifuture_simple_rpc(p_int_parameter);
69 apache::thrift::detail::si::async_tm_semifuture(std::move(callback), std::move(fut));
70 return;
72 case apache::thrift::detail::si::InvocationType::Sync:
74 ::test::fixtures::basic::ReservedKeyword _return;
75 simple_rpc(_return, p_int_parameter);
76 callback->result(_return);
77 return;
79 default:
81 folly::assume_unreachable();
84 } catch (...) {
85 callback->exception(std::current_exception());
90 namespace test { namespace fixtures { namespace basic {
92 void FB303ServiceSvNull::simple_rpc(::test::fixtures::basic::ReservedKeyword& /*_return*/, ::std::int32_t /*int_parameter*/) {}
95 const char* FB303ServiceAsyncProcessor::getServiceName() {
96 return "FB303Service";
99 void FB303ServiceAsyncProcessor::getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
100 ::apache::thrift::detail::md::ServiceMetadata<::apache::thrift::ServiceHandler<::test::fixtures::basic::FB303Service>>::gen(response);
103 void FB303ServiceAsyncProcessor::processSerializedCompressedRequest(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
104 apache::thrift::detail::ap::process(this, std::move(req), std::move(serializedRequest), protType, context, eb, tm);
107 void FB303ServiceAsyncProcessor::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) {
108 apache::thrift::detail::ap::process(this, iface_, std::move(req), std::move(serializedRequest), methodMetadata, protType, context, eb, tm);
111 void FB303ServiceAsyncProcessor::executeRequest(apache::thrift::ServerRequest&& request, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata) {
112 apache::thrift::detail::ap::execute(this, std::move(request), apache::thrift::detail::ServerRequestHelper::protocol(request), methodMetadata);
115 const FB303ServiceAsyncProcessor::ProcessMap& FB303ServiceAsyncProcessor::getOwnProcessMap() {
116 return kOwnProcessMap_;
119 const FB303ServiceAsyncProcessor::ProcessMap FB303ServiceAsyncProcessor::kOwnProcessMap_ {
120 {"simple_rpc",
121 {&FB303ServiceAsyncProcessor::setUpAndProcess_simple_rpc<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter>,
122 &FB303ServiceAsyncProcessor::setUpAndProcess_simple_rpc<apache::thrift::BinaryProtocolReader, apache::thrift::BinaryProtocolWriter>,
123 &FB303ServiceAsyncProcessor::executeRequest_simple_rpc<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter>,
124 &FB303ServiceAsyncProcessor::executeRequest_simple_rpc<apache::thrift::BinaryProtocolReader, apache::thrift::BinaryProtocolWriter>}},
127 apache::thrift::ServiceRequestInfoMap const& FB303ServiceServiceInfoHolder::requestInfoMap() const {
128 static folly::Indestructible<apache::thrift::ServiceRequestInfoMap> requestInfoMap{staticRequestInfoMap()};
129 return *requestInfoMap;
132 apache::thrift::ServiceRequestInfoMap FB303ServiceServiceInfoHolder::staticRequestInfoMap() {
133 apache::thrift::ServiceRequestInfoMap requestInfoMap = {
134 {"simple_rpc",
135 {false,
136 apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE,
137 "FB303Service.simple_rpc",
138 std::nullopt,
139 apache::thrift::concurrency::NORMAL}},
142 return requestInfoMap;
144 }}} // test::fixtures::basic