From 3854d9fcd58b554c073d828ab2eda4e5c07f97ce Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Fri, 3 Mar 2023 16:55:47 -0800 Subject: [PATCH] Document proper way to set services. PiperOrigin-RevId: 513955214 --- mediapipe/framework/calculator_graph.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mediapipe/framework/calculator_graph.h b/mediapipe/framework/calculator_graph.h index 22dd7e54..85febaa2 100644 --- a/mediapipe/framework/calculator_graph.h +++ b/mediapipe/framework/calculator_graph.h @@ -383,6 +383,12 @@ class CalculatorGraph { absl::Status SetGpuResources(std::shared_ptr resources); #endif // !MEDIAPIPE_DISABLE_GPU + // Sets a service object, essentially a graph-level singleton, which can be + // accessed by calculators and subgraphs without requiring an explicit + // connection. + // + // NOTE: must be called before `Initialize`, so subgraphs can access services + // as well, as graph expansion happens during initialization. template absl::Status SetServiceObject(const GraphService& service, std::shared_ptr object) { @@ -395,6 +401,13 @@ class CalculatorGraph { return service_manager_.GetServiceObject(service); } + // Sets a service object, essentially a graph-level singleton, which can be + // accessed by calculators and subgraphs without requiring an explicit + // connection. + // + // NOTE: must be called before `Initialize`, so subgraphs can access services + // as well, as graph expansion happens during initialization. + // // Only the Java API should call this directly. absl::Status SetServicePacket(const GraphServiceBase& service, Packet p) { // TODO: check that the graph has not been started!