The Observer Model Trail
This section will explain the Codelet Observer Model, in which the Codelet is a Memory Observer.
The Memory Observer Codelet
In this feature, a Memory Object will be observed by a Codelet. This means that the Codelet will be notified when the info in the Memory Object changes. This allows the Codelet to run its proc() method only when the info changes and it does not run attached to a Timer, as it usually runs.
Why it is necessary?
This feature was developed as a necessity for limited environments, like mobile devices, for instance. In a limited environment, when the Codelet runs indiscriminately over time, it can exhaust the environment's resources, but when running as a Memory Observer it will run just when needed, and thus avoid the exhaustion.
How to use it?
First, define your Codelet:
![]()
Then, create your Codelet and set it as a Memory Observer, with the method setIsMemoryObserver(boolean isMemoryObserver), and add it to the Memory you want to observe with the memory method, addMemoryObserver(MemoryObserver memoryObserver):
And that's it! Only when the MemoryObject mo has a call to its method setI(Object info), the CodeletToTest c will be notified and will run its method proc().