14 #include <boost/asio/io_context.hpp> 15 #include <boost/asio/post.hpp> 17 #include <rpc/server.h> 40 template <
typename... Args>
41 explicit Server(Args &&... args);
43 template <
typename FunctorT>
46 template <
typename FunctorT>
50 _server.async_run(worker_threads);
54 #ifdef LIBCARLA_INCLUDED_FROM_UE4 56 TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
58 #endif // LIBCARLA_INCLUDED_FROM_UE4 84 template <
typename C,
typename R,
typename... Args>
87 template <
typename C,
typename R,
typename... Args>
96 template <
typename R,
typename... Args>
108 template <
typename FuncT>
109 static auto WrapSyncCall(boost::asio::io_context &io, FuncT &&functor) {
110 return [&io, functor=std::forward<FuncT>(functor)](
Metadata metadata, Args... args) -> R {
111 auto task = std::packaged_task<R()>([functor=std::move(functor), args...]() {
112 return functor(args...);
120 auto result = task.get_future();
130 template <
typename FuncT>
132 return [functor=std::forward<FuncT>(functor)](::
carla::rpc::Metadata metadata, Args... args) -> R {
137 return functor(args...);
145 template <
typename ... Args>
148 _server.suppress_exceptions(
true);
151 template <
typename FunctorT>
159 template <
typename FunctorT>
164 Wrapper::WrapAsyncCall(std::forward<FunctorT>(functor)));
void AsyncRun(size_t worker_threads)
static auto WrapAsyncCall(FuncT &&functor)
Wraps functor into a function type with equivalent signature that handles the metadata sent by the cl...
void BindSync(const std::string &name, FunctorT &&functor)
carla::rpc::Response< T > R
This file contains definitions of common data structures used in traffic manager. ...
An RPC server in which functions can be bind to run synchronously or asynchronously.
void BindAsync(const std::string &name, FunctorT &&functor)
boost::asio::io_context _sync_io_context
auto MoveHandler(FunctorT &&func)
Hack to trick asio into accepting move-only handlers, if the handler were actually copied it would re...
static auto WrapSyncCall(boost::asio::io_context &io, FuncT &&functor)
Wraps functor into a function type with equivalent signature.
Positive time duration up to milliseconds resolution.
void SyncRunFor(time_duration duration)
constexpr auto to_chrono() const