template <typename ServerT, template <typename ProtocolT> typename FidlServerT, typename ProtocolT>
class BaseFidlServer
Defined at line 67 of file ../../src/media/audio/services/common/base_fidl_server.h
Base class for FIDL servers. Example of use:
```cpp
class ProtocolServer : public BaseFidlServer
<ProtocolServer
, fidl::WireServer
<Protocol
>> {
public:
static std::shared_ptr
<ProtocolServer
> Create(std::shared_ptr
<const
FidlThread> thread,
fidl::ServerEnd
<Protocol
> server_end,
int arg) {
return BaseFidlServer::Create(std::move(thread), std::move(server_end), arg);
}
// Override all methods from fidl::WireServer
<Protocol
>
// ...
private:
static inline const std::string_view kClassName = "ProtocolServer";
template
<typename
ServerT, template
<typename
T> typename FidlServerT, typename ProtocolT>
friend class BaseFidlServer;
ProtocolServer(int arg);
};
```
As shown above, subclasses should be created via a `Create` static method that calls
into `BaseFidlServer::Create`. The `FidlServerT` template argument can be `fidl::Server
<
>` or
`fidl::WireServer`.
Public Methods
const FidlThread & thread ()
Returns the thread used by this server.
Defined at line 72 of file ../../src/media/audio/services/common/base_fidl_server.h
std::shared_ptr<const FidlThread> thread_ptr ()
Like thread, but returns a `std::shared_ptr` which can be copied.
Defined at line 75 of file ../../src/media/audio/services/common/base_fidl_server.h
void Shutdown (zx_status_t epitaph)
Triggers a shutdown of this server using the given epitaph. The actual shutdown process happens
asynchronously. This may be called from any thread. After the first call, subsequent calls are
no-ops.
Defined at line 80 of file ../../src/media/audio/services/common/base_fidl_server.h
bool WaitForShutdown (zx::duration timeout)
Waits until the server and all its children have shut down. This does not actually shut down
any servers -- shutdown must be triggered separately. A server can be shutdown either via an
explicit call to `Shutdown` or by closing the client channel, both of which trigger shutdown
asynchronously. This is a blocking call that can be invoked from any thread. This is primarily
intended for tests.
Returns false if the server(s) do not shutdown before the given timeout has expired.
Defined at line 89 of file ../../src/media/audio/services/common/base_fidl_server.h
Protected Methods
void BaseFidlServer<ServerT, FidlServerT, ProtocolT> ()
Defined at line 113 of file ../../src/media/audio/services/common/base_fidl_server.h
const fidl::ServerBindingRef<ProtocolT> & binding ()
Defined at line 115 of file ../../src/media/audio/services/common/base_fidl_server.h
template <typename... Args>
std::shared_ptr<ServerT> Create (std::shared_ptr<const FidlThread> thread, fidl::ServerEnd<ProtocolT> server_end, Args... args)
Helper to create a server. The ServerT object is constructed via `ServerT(args...)`.
Methods received on `server_end` will be dispatched on `thread->dispatcher()`.
Defined at line 120 of file ../../src/media/audio/services/common/base_fidl_server.h
void OnShutdown (fidl::UnbindInfo info)
Invoked on `thread()` as the last step before the server shuts down.
Can be overridden by subclasses.
Defined at line 148 of file ../../src/media/audio/services/common/base_fidl_server.h
void AddChildServer (const std::shared_ptr<internal::BaseFidlServerUntyped> & server)
Adds a child server. The child is held as a weak_ptr so it will be automatically
garbage collected after it is destroyed.
Defined at line 158 of file ../../src/media/audio/services/common/base_fidl_server.h