ALMemory provides a centralized memory that can be used to store and retrieve named values. It also acts as a hub for the distribution of event notifications.
ALMemory is a mutexed and unordered boost map. The map contains variant (ALValue).
Mutex are read/write mutex and for performance, can protect:
For example:
The notifications are managed by a threadpool (in local) or by a unique notification thread (in remote).
Event is a MicroEvent which store his history into ALMemory. They are basically the same, but MicroEvent is faster.
You can access to event history using ALMemoryProxy::getEventHistory.
Furthermore Module can autostart when someone subscribe to an Event. This feature is accessible using ALMemoryProxy::declareEvent with two parameters.
ALMemory is thread safe for normal operations. Reader and writer can access variable at the same moment except when you use ALMemoryProxy::getDataPtr.
AMD Geode performance:
Method | Performance |
---|---|
10 insertData | 0.01 ms |
10 raiseMicroEvent | 0.015ms |
10 raiseEvent | 0.02 ms |
10 python insertData | 1.0 ms |
ALMemory can store and retreive variant (ALValue):
type | C++ | Python | Java |
---|---|---|---|
integer | int | Python integer | int |
boolean | bool | Python boolean | Boolean |
float | float | Python float | Float |
List | vector<ALValue> | [] | Java array [] |
String | std::string | Python string | String |
Binary | ALValue | String | byte[] |
Variant | ALValue | Use python type | jnaoqi Variant |
To access to a value stored in ALMemory, use ALMemoryProxy::getDataPtr and ALMemoryProxy::getData.
ALMemoryProxy::getDataPtr provides fast pointer access.
Warning: it’s not thread safe nor atomic.
ALMemoryProxy::getData provides thread safe access.
It can be used either when your module is local or remote.
To store values in the memory, use ALMemoryProxy::insertData.
To subscribe to events, use the following functions:
Look at the following example for details: Creating events
To generate events, use the following functions: