template <typename T> class SharedHandle final {...};
Handle to a File Storage or Key-Value Storage. A SharedHandle is returned by the functions OpenFileStorage() and OpenKeyValueStorage() and can be passed between threads as needed. It provides the abstraction that is necessary to allow thread-safe implementation of OpenFile Storage() and OpenKeyValueStorage().
Enables thread-safe access to file and key-value storages across thread boundaries.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 7420a4e54761ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Enables thread-safe access to file and key-value storages across thread boundaries.
The template class ara::per::SharedHandle serves as a smart-pointer abstraction for file and key-value storages to enable thread-safe access across thread boundaries. After obtaining it via factory functions, the validity state of the handle must be checked via operator bool()[SWS_PER_00398], as calling other operators on an empty handle or one invalidated by move operations results in undefined behavior. While dereferencing to the encapsulated object is thread-safe, assignments and destruction of the handle [SWS_PER_00568] on the same instance require external synchronization.
Context
The template class ara::per::SharedHandle represents a smart-pointer abstraction for persistent storage resources in the per (Persistency) module of the AUTOSAR Adaptive Platform. It serves as the standardized return type of the factory functions OpenFileStorage() and OpenKeyValueStorage(). The main responsibility of the class is to coordinate access to file and key-value storages across thread boundaries and to provide the necessary encapsulation to enable a thread-safe implementation of storage opening and access routines. Interaction partners are application-side threads of execution, persistency management, and the respective encapsulated storage resource T.
Lifecycle
A SharedHandle is typically created when opening a storage instance via the factory interfaces of per. Through the copy constructor [SWS_PER_00369] as well as the copy assignment operator [SWS_PER_00370], the handle can be duplicated, whereby multiple handle instances obtain shared access to the same target object. If a handle is transferred by means of the move constructor [SWS_PER_00367] or move assignment [SWS_PER_00368], the source handle transitions to an invalidated state and may no longer be used for storage accesses.
The current status of the handle is determined by the explicit conversion operator operator bool()[SWS_PER_00398]: it returns true if a valid storage instance is referenced, and false if the handle is empty. Release of the handle resources occurs via the destructor ~SharedHandle()[SWS_PER_00568]. Interpretation: the underlying storage resource is likely to be released as soon as the last referencing SharedHandle is destroyed. Question Q-00a1798cf43e0ee6 (open)
Critical error states occur primarily during invalid operations on empty or invalidated handles. According to [SWS_PER_00398], calling any operators other than operator bool() on an empty handle leads directly to undefined behavior. This particularly affects source handles after a move construction [SWS_PER_00367] or a move assignment [SWS_PER_00368], since these are invalidated and may not be used further.
Move constructor for SharedHandle. The source handle object is invalidated and cannot be used anymore. The operator bool() shall be used to check the state of a handle object before using any other operators of the handle object.
Move assignment operator for SharedHandle. The source handle object is invalidated and cannot be used anymore. The operator bool() shall be used to check the state of a handle object before using any other operators of the handle object.
Handle state. True if the handle represents a valid object of the templated class, False if the handle is empty (e.g. after a move operation). Using other operators than bool() of an empty handle will result in undefined behavior.
Move constructor for SharedHandle. The source handle object is invalidated and cannot be used anymore. The operator bool() shall be used to check the state of a handle object before using any other operators of the handle object.
Move assignment operator for SharedHandle. The source handle object is invalidated and cannot be used anymore. The operator bool() shall be used to check the state of a handle object before using any other operators of the handle object.
Handle state. True if the handle represents a valid object of the templated class, False if the handle is empty (e.g. after a move operation). Using other operators than bool() of an empty handle will result in undefined behavior.
gemini-3.8-flash-low· 2026-10-13 · German original