Lifecycle and resource cleanup
General reference
Lifecycle and scope
| Object | Method | Scope and behavior |
|---|---|---|
Sdk | start() | Connects and starts all enabled devices and capabilities that are not yet closed, in configuration order; states that are already satisfied can be called again |
Sdk | update() | Performs one manual update of the entire SDK and returns a one-shot wait result |
Sdk | run_forever() / run_background() | Runs the entire SDK in foreground or background mode; both modes are mutually exclusive with manual update |
Sdk | request_stop() / join() | Requests the current run loop to stop; join() waits for the background run to finish and reports background errors |
Sdk | stop() | Stops all started capabilities and data streams, then disconnects all connected devices; start() can be called again afterwards |
Sdk | health() | Returns the aggregated health status of all devices and capabilities that are not closed |
Sdk | close() | Requests stop, waits for the run to finish, cleans up subscriptions, and releases all SDK resources; after complete cleanup, repeated calls are a no-op |
Glove | start() / stop() | Acts only on all enabled gloves that are not yet closed |
Glove | update() / run_forever() / run_background() | Handles glove data only; the run mode rules are the same as for Sdk |
Glove | request_stop() / join() / health() | Stops or observes the glove run state without affecting other SDK capabilities |
Glove | close() | Stops and closes all configured gloves; the Sdk itself can still be used for other capabilities that are not closed |
GloveDevice | start() / stop() | Acts only on the selected physical glove; does not change the state of other devices |
GloveDevice | push_frame() | Only allows an external connection to submit one input frame while connected and started |
Closing and resource cleanup
Lifecycle failures report LifecycleError, while features unavailable for the current device or configuration report UnavailableFeatureError; do not catch only WorkflowError.
An explicit close() is the primary cleanup method; destruction only provides a non-throwing
last resort.
Glove::close() reclaims subscriptions that are still valid. The application only needs to keep
the corresponding Subscription objects alive; there is no need to unsubscribe them one by one
before the final close. Call subscription.unsubscribe() explicitly only when the owning object
keeps running but a single callback needs to be stopped early.
Do not synchronously call unsubscribe() on, or destroy, that subscription from inside its own
callback.
Finite tasks call Glove::close() when the normal path ends; background mode calls
request_stop() and join() first. Glove::close() stops and closes all configured gloves, and
Sdk::close() closes the remaining capabilities and releases the entire SDK. After a successful
close, repeated calls are a no-op.
The destructors of Subscription, Glove, and Sdk still provide an RAII fallback, but they
cannot replace an explicit close(), because destruction cannot reliably report cleanup
failures. Also do not destroy the last Sdk object inside a callback; leave cleanup to the
application control path outside the callback.
Sdk, Glove, and GloveDevice still provide connect() and disconnect(). connect() is
kept only for compatibility with old code and does not open devices; disconnect() is equivalent
to stop(). New code should use start() and stop() directly.