What it does¶
ALMemory is a centralized memory used to store all key information related to the hardware configuration of your robot.
ALMemory can also be used to store and retrieve named values, and act as a hub for the distribution of event notifications.
How it works¶
ALMemory is a mutexed and unordered boost map. The map contains variant (ALValue).
Mutex are read/write mutex and for performance, can protect:
- The map
- A value
- The value history (only for events)
- Remove a data blocks all readers/writers.
- Insert an existing data only blocks the modified data.
- Read data blocks only writers of read data.
The notifications are managed by a threadpool (in local) or by a unique notification thread (in remote).
Event and MicroEvent¶
An Event is a MicroEvent which stores his history into ALMemory. They are basically the same, but MicroEvent is faster.
You can access to event history using
Furthermore a Module can autostart when someone subscribe to an Event.
This feature is accessible using
ALMemoryProxy::declareEvent with two parameters.
Performances and Limitations¶
ALMemory is thread safe for normal operations. Reader and writer can access
variable at the same moment except when you use
ALMemory can store and retrieve variant (ALValue):
|List||vector<ALValue>||||Java array |
|Variant||ALValue||Use python type||jnaoqi Variant|
ALMemory only stores 4-byte integers and 4-byte floats. This is not a problem for C++ as it uses the same representation, but Python integers and floats are 8 bytes (or more for big ints). This may lead to a loss of precision when storing values.
To access to a value stored in ALMemory, use:
|The function ...||Providing ...|
Fast pointer access.
Warning: it’s not thread safe nor atomic.
Thread safe access.
It can be used either when your module is local or remote.
To store values in the memory, use
To subscribe to events, use:
|The function ...||To subscribe to ...|
For further details, see the following example: Creating events (DEPRECATED).
To generate events, use the following functions:
|The function ...||To ...|
||insert a value and notify subscribers.|
||insert a value, notify subscribers, store value history and timestamp (internal).|
link a module to a variable.
If a module subscribes to variable, the module starts his process once.
For example, subscribe to