/**
 * Autogenerated by Thrift for thrift/compiler/test/fixtures/adapter/src/module.thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

#include <thrift/compiler/test/fixtures/adapter/gen-py3/module/services_wrapper.h>
#include <thrift/compiler/test/fixtures/adapter/gen-py3/module/services_api.h>
#include <thrift/lib/cpp2/async/AsyncProcessor.h>

namespace facebook {
namespace thrift {
namespace test {

ServiceWrapper::ServiceWrapper(PyObject *obj, folly::Executor* exc)
  : if_object(obj), executor(exc)
  {
    import_facebook__thrift__test__module__services();
  }


void ServiceWrapper::async_tm_func(
  apache::thrift::HandlerCallbackPtr<int32_t> callback
    , std::unique_ptr<std::string> arg1
    , std::unique_ptr<std::string> arg2
    , std::unique_ptr<::facebook::thrift::test::Foo> arg3
) {
  auto ctx = callback->getRequestContext();
  folly::via(
    this->executor,
    [this, ctx,
     callback = std::move(callback),
arg1 = std::move(arg1),
arg2 = std::move(arg2),
arg3 = std::move(arg3)    ]() mutable {
        auto [promise, future] = folly::makePromiseContract<int32_t>();
        call_cy_Service_func(
            this->if_object,
            ctx,
            std::move(promise),
            std::move(arg1),
            std::move(arg2),
            std::move(arg3)        );
        std::move(future).via(this->executor).thenTry([callback = std::move(callback)](folly::Try<int32_t>&& t) {
          (void)t;
          callback->complete(std::move(t));
        });
    });
}
std::shared_ptr<apache::thrift::ServerInterface> ServiceInterface(PyObject *if_object, folly::Executor *exc) {
  return std::make_shared<ServiceWrapper>(if_object, exc);
}
folly::SemiFuture<folly::Unit> ServiceWrapper::semifuture_onStartServing() {
  auto [promise, future] = folly::makePromiseContract<folly::Unit>();
  call_cy_Service_onStartServing(
      this->if_object,
      std::move(promise)
  );
  return std::move(future);
}
folly::SemiFuture<folly::Unit> ServiceWrapper::semifuture_onStopRequested() {
  auto [promise, future] = folly::makePromiseContract<folly::Unit>();
  call_cy_Service_onStopRequested(
      this->if_object,
      std::move(promise)
  );
  return std::move(future);
}


AdapterServiceWrapper::AdapterServiceWrapper(PyObject *obj, folly::Executor* exc)
  : if_object(obj), executor(exc)
  {
    import_facebook__thrift__test__module__services();
  }


void AdapterServiceWrapper::async_tm_count(
  apache::thrift::HandlerCallbackPtr<std::unique_ptr<::facebook::thrift::test::CountingStruct>> callback) {
  auto ctx = callback->getRequestContext();
  folly::via(
    this->executor,
    [this, ctx,
     callback = std::move(callback)    ]() mutable {
        auto [promise, future] = folly::makePromiseContract<std::unique_ptr<::facebook::thrift::test::CountingStruct>>();
        call_cy_AdapterService_count(
            this->if_object,
            ctx,
            std::move(promise)        );
        std::move(future).via(this->executor).thenTry([callback = std::move(callback)](folly::Try<std::unique_ptr<::facebook::thrift::test::CountingStruct>>&& t) {
          (void)t;
          callback->complete(std::move(t));
        });
    });
}
void AdapterServiceWrapper::async_tm_adaptedTypes(
  apache::thrift::HandlerCallbackPtr<std::unique_ptr<::facebook::thrift::test::HeapAllocated>> callback
    , std::unique_ptr<::facebook::thrift::test::HeapAllocated> arg
) {
  auto ctx = callback->getRequestContext();
  folly::via(
    this->executor,
    [this, ctx,
     callback = std::move(callback),
arg = std::move(arg)    ]() mutable {
        auto [promise, future] = folly::makePromiseContract<std::unique_ptr<::facebook::thrift::test::HeapAllocated>>();
        call_cy_AdapterService_adaptedTypes(
            this->if_object,
            ctx,
            std::move(promise),
            std::move(arg)        );
        std::move(future).via(this->executor).thenTry([callback = std::move(callback)](folly::Try<std::unique_ptr<::facebook::thrift::test::HeapAllocated>>&& t) {
          (void)t;
          callback->complete(std::move(t));
        });
    });
}
std::shared_ptr<apache::thrift::ServerInterface> AdapterServiceInterface(PyObject *if_object, folly::Executor *exc) {
  return std::make_shared<AdapterServiceWrapper>(if_object, exc);
}
folly::SemiFuture<folly::Unit> AdapterServiceWrapper::semifuture_onStartServing() {
  auto [promise, future] = folly::makePromiseContract<folly::Unit>();
  call_cy_AdapterService_onStartServing(
      this->if_object,
      std::move(promise)
  );
  return std::move(future);
}
folly::SemiFuture<folly::Unit> AdapterServiceWrapper::semifuture_onStopRequested() {
  auto [promise, future] = folly::makePromiseContract<folly::Unit>();
  call_cy_AdapterService_onStopRequested(
      this->if_object,
      std::move(promise)
  );
  return std::move(future);
}
} // namespace facebook
} // namespace thrift
} // namespace test
