probe_index probe_subscribe
API Reference Manual  /  7 Simulator-to-Simulator Interfaces  / 

probe_sampler_cache

Description
This interface is implemented by the singleton probes object. The interface is expected to be used by either probe-samplers (enable, disable or by a probe which supports caching (get_generation_id).

When a probe-sampler calls the enable method, caching can start. Caching depends on a generation id, this is automatically increased by enable.

With caching enabled, probes can return the previous value back, avoiding expensive calculation, if they are read multiple times (either directly, or indirectly from other probes). It can also be used to avoid probe values to return a slightly different value the next time in the same sample, such as wallclock time.

A probe which wants to use caching needs to call the get_generation_id method. As long as the generation id is the same as the last time the probe-value was returned, the same probe-value can be returned. Otherwise a new value needs to be returned. Generation id zero, is special, it means that caching is not currently enabled.

When sampling is finished the probe_sampler calls the disable which will cause the generation id zero to be returned until the next sample begins again.

SIM_INTERFACE(probe_sampler_cache) {
        void (*enable)(conf_object_t *obj);
        void (*disable)(conf_object_t *obj);

        uint64 (*get_generation)(conf_object_t *obj);
};
#define PROBE_SAMPLER_CACHE_INTERFACE "probe_sampler_cache"

Execution Context
Global Context for all methods.

probe_index probe_subscribe