Start an asynchronous FindService notification about service updates.

notice

Note: The callback handler might execute before this function returns. Therefore, do not call StopFindService() within the callback, as it requires the FindServiceHandle returned by this function.

There are two ways the function can find service instances:

  1. from the InstanceIdentifier
  2. from the InstanceSpecifier

Syntax

//Find service from InstanceIdentifier
FindServiceHandle ServiceInterfaceProxy::StartFindService(FindServiceHandler<HandleType> handler, InstanceIdentifier instance)

//Find service from InstanceSpecifier
FindServiceHandle ServiceInterfaceProxy::StartFindService(FindServiceHandler<HandleType> handler, InstanceSpecifier instance)

Parameters

in

handler

Gets called upon detection of a matching service. This parameter cannot be nullptr.

in

instance

InstanceIdentifier or InstanceSpecifier to be searched.

Returns

FindServiceHandle

The Handle is needed to stop the service availability monitoring and related firing of the given handler.

notice

Note: The handles received by this callback shall be released before the runtime is destroyed. They cannot be stored in variables with longer life period than the application's main().

If not followed, it's not guaranteed that the communication middleware is shut down properly and may lead to segmentation fault.

Any exception thrown by the callback will lead to a termination through std::terminate().

Precondition

Thread-safety, Reentrance, Result Delivery

Example

class RPortExampleServiceConsumer final {
public:

  using TyServiceProxy = services::exampleservice::proxy::ExampleServiceProxy;

}

 

void RPortExampleServiceConsumer::StartServiceConsumer(ara::core::InstanceSpecifier example_instance_spec) noexcept {

  opt_find_service_handle_ = TyServiceProxy::StartFindService(
    [this](ara::com::ServiceHandleContainer<TyServiceProxy::HandleType> service_handle_container) {
      …
    }, example_instance_spec);
}