CARLA
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
carla::rpc::Server Class Reference

An RPC server in which functions can be bind to run synchronously or asynchronously. More...

#include <Server.h>

Public Member Functions

void AsyncRun (size_t worker_threads)
 
template<typename FunctorT >
void BindAsync (const std::string &name, FunctorT &&functor)
 
template<typename FunctorT >
void BindSync (const std::string &name, FunctorT &&functor)
 
template<typename... Args>
 Server (Args &&... args)
 
void Stop ()
 
void SyncRunFor (time_duration duration)
 

Private Attributes

::rpc::server _server
 
std::atomic_bool _shutdown_in_progress {false}
 
boost::asio::io_context _sync_io_context
 

Detailed Description

An RPC server in which functions can be bind to run synchronously or asynchronously.

Use AsyncRun to start the worker threads, and use SyncRunFor to run a slice of work in the caller's thread.

Functions that are bind using BindAsync will run asynchronously in the worker threads. Functions that are bind using BindSync will run within SyncRunFor function.

Definition at line 40 of file rpc/Server.h.

Constructor & Destructor Documentation

◆ Server()

template<typename ... Args>
carla::rpc::Server::Server ( Args &&...  args)
inlineexplicit

Definition at line 159 of file rpc/Server.h.

References _server.

Member Function Documentation

◆ AsyncRun()

void carla::rpc::Server::AsyncRun ( size_t  worker_threads)
inline

Definition at line 52 of file rpc/Server.h.

References _server.

Referenced by TEST().

◆ BindAsync()

template<typename FunctorT >
void carla::rpc::Server::BindAsync ( const std::string &  name,
FunctorT &&  functor 
)
inline

Definition at line 173 of file rpc/Server.h.

References _server.

Referenced by ServerBinder::operator<<().

◆ BindSync()

template<typename FunctorT >
void carla::rpc::Server::BindSync ( const std::string &  name,
FunctorT &&  functor 
)
inline

Definition at line 165 of file rpc/Server.h.

References _server, _shutdown_in_progress, and _sync_io_context.

Referenced by ServerBinder::operator<<(), TEST(), and TEST().

◆ Stop()

void carla::rpc::Server::Stop ( )
inline
Warning
does not stop the game thread.

Definition at line 67 of file rpc/Server.h.

References _server, and _shutdown_in_progress.

◆ SyncRunFor()

void carla::rpc::Server::SyncRunFor ( time_duration  duration)
inline

Definition at line 56 of file rpc/Server.h.

References _sync_io_context, and carla::time_duration::to_chrono().

Referenced by TEST().

Member Data Documentation

◆ _server

::rpc::server carla::rpc::Server::_server
private

Definition at line 76 of file rpc/Server.h.

Referenced by AsyncRun(), BindAsync(), BindSync(), Server(), and Stop().

◆ _shutdown_in_progress

std::atomic_bool carla::rpc::Server::_shutdown_in_progress {false}
private

Definition at line 77 of file rpc/Server.h.

Referenced by BindSync(), and Stop().

◆ _sync_io_context

boost::asio::io_context carla::rpc::Server::_sync_io_context
private

Definition at line 74 of file rpc/Server.h.

Referenced by BindSync(), and SyncRunFor().


The documentation for this class was generated from the following file: