Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_rpc
  6. pw::rpc::Rpc2Adapter Class Reference
pw::rpc::Rpc2Adapter Class Referencefinal

Overview

Runs pw_rpc services on a pw::rpc2::Server without an existing pw::rpc::Server.

Use this when adapted services only need to serve pw_rpc2 clients, and use Rpc2ServerAdapter when adapted services also serve pw_rpc clients on an existing pw::rpc::Server. Register services with this adapter using Rpc2ServiceFor.

Like Rpc2ServerAdapter, it must never be destroyed if the pw_thread backend does not support joining.

Example
pw::rpc2::Server rpc2_server(allocator, dispatcher);
// Create an adapter for running pw_rpc services without an existing
// pw::rpc::Server.
pw::rpc::Rpc2Adapter adapter(adapter_allocator, thread_options);
// Construct, own, and register SensorServiceImpl with the adapter.
PW_CHECK_OK(rpc2_server.RegisterService(sensor_service));
Definition: server.h:76
Definition: rpc2_adapter.h:381
Definition: rpc2_adapter.h:497
#define PW_CHECK_OK(expression,...)
Definition: check_impl.h:308
Source: pw_rpc/examples/use_rpc_services_in_rpc2.cc
Inheritance diagram for pw::rpc::Rpc2Adapter:
pw::rpc::Rpc2ServerAdapter

Public Member Functions

 Rpc2Adapter (Allocator &allocator, const thread::Options &options, const Rpc2AdapterConfig &config=Rpc2AdapterConfig())
 
- Public Member Functions inherited from pw::rpc::Rpc2ServerAdapter
 Rpc2ServerAdapter (Server &server, Allocator &allocator, const thread::Options &options, const Rpc2AdapterConfig &config=Rpc2AdapterConfig())
 
 ~Rpc2ServerAdapter ()
 
 Rpc2ServerAdapter (const Rpc2ServerAdapter &)=delete
 
Rpc2ServerAdapter & operator= (const Rpc2ServerAdapter &)=delete
 
template<int &... kExplicitGuard, bool kJoiningEnabled = PW_THREAD_JOINING_ENABLED>
void Stop ()
 

Constructor & Destructor Documentation

◆ Rpc2Adapter()

pw::rpc::Rpc2Adapter::Rpc2Adapter ( Allocator &  allocator,
const thread::Options &  options,
const Rpc2AdapterConfig &  config = Rpc2AdapterConfig() 
)
inline

Creates an adapter and starts the worker thread that runs pw_rpc handlers for pw_rpc2 clients.

Parameters
[in]allocatorBuffers in-flight packets and holds per-connection state. Accessed under the adapter's lock, so it need not be thread-safe unless shared outside the adapter.
[in]optionsOptions for the worker thread. Anything options references (such as a stack or thread context) must outlive the adapter.
[in]configChannel assignment and buffering limits.

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