Contains global-state helper macros. More...
Macros | |
| #define | __PICOTM_GLOBAL_STATE_GET(_name) |
| #define | __PICOTM_GLOBAL_STATE_IMPL(_static, _name) |
| #define | __PICOTM_GLOBAL_STATE_REF(_name) |
| #define | __PICOTM_GLOBAL_STATE_UNREF(_name) |
| #define | PICOTM_GLOBAL_STATE_GET(_name) |
| #define | PICOTM_GLOBAL_STATE_REF(_name, _error) |
| #define | PICOTM_GLOBAL_STATE_STATIC_IMPL(_name) |
| #define | PICOTM_GLOBAL_STATE_UNREF(_name) |
Picotm provides helper macros for maintaining shared state. Oftentimes a single shared state is used throughout a module. For this case, picotm provides additional helper macros that maintain such global state. The example below declares shared state of type struct shared.
A single global state variable for an existing shared state is declared with PICOTM_GLOBAL_STATE_STATIC_IMPL(). This macro receives the name of the shared state and expands to an implementation.
Users acquire a reference to the global state with PICOTM_GLOBAL_STATE_REF() and release a previously acquired reference with a call to PICOTM_GLOBAL_STATE_UNREF().
Global state is implemented on top of shared state, so the same rules for thread-safety apply. All references and releases are serialized with each other and the initializer and clean-up functions. Concurrent access to shared data files requires additional concurrency control.
| #define __PICOTM_GLOBAL_STATE_GET | ( | _name | ) |
| #define __PICOTM_GLOBAL_STATE_IMPL | ( | _static, | |
| _name | |||
| ) |
| #define __PICOTM_GLOBAL_STATE_REF | ( | _name | ) |
| #define __PICOTM_GLOBAL_STATE_UNREF | ( | _name | ) |