Class IPayloadPool
Defined in File IPayloadPool.h
Class Documentation
-
class IPayloadPool
An interface for classes responsible of serialized payload management.
Public Functions
-
virtual ~IPayloadPool() = default
-
virtual bool get_payload(uint32_t size, CacheChange_t &cache_change) = 0
Get a serialized payload for a new sample.
This method will usually be called in one of the following situations:
When a writer creates a new cache change
When a reader receives the first fragment of a cache change
sizewill be for the whole serialized payload.- Parameters
size – [in] Number of bytes required for the serialized payload. Should be greater than 0.
cache_change – [inout] Cache change to assign the payload to
- Returns
whether the operation succeeded or not
- Pre
Fields
writerGUIDandsequenceNumberofcache_changeare either:Both equal to
unknown(meaning a writer is creating a new change)Both different from
unknown(meaning a reader has received the first fragment of a cache change)
- Post
Field
cache_change.payload_ownerequals thisField
serializedPayload.datapoints to a buffer of at leastsizebytesField
serializedPayload.max_sizeis greater than or equal tosize
-
virtual bool get_payload(SerializedPayload_t &data, IPayloadPool *&data_owner, CacheChange_t &cache_change) = 0
Assign a serialized payload to a new sample.
This method will usually be called when a reader receives a whole cache change.
Note
dataanddata_ownerare received as references to accommodate the case where several readers receive the same payload. If the payload has no owner, it means it is allocated on the stack of a reception thread, and a copy should be performed. The pool may decide in that case to pointdata.datato the new copy and take ownership of the payload. In that case, when the reception thread is done with the payload (after all readers have been informed of the received data), methodrelease_payloadwill be called to indicate that the reception thread is not using the payload anymore.Warning
data_ownercan only be changed fromnullptrtothis. If a value different fromnullptris received it should be left unchanged.Warning
datafields can only be changed whendata_ownerisnullptr. If a value different fromnullptris received all fields indatashould be left unchanged.- Parameters
data – [inout] Serialized payload received
data_owner – [inout] Payload pool owning incoming data
cache_change – [inout] Cache change to assign the payload to
- Returns
whether the operation succeeded or not
- Pre
Field
cache_change.writerGUIDis notunknownField
cache_change.sequenceNumberis notunknown
- Post
Field
cache_change.payload_ownerequals thisField
cache_change.serializedPayload.datapoints to a buffer of at leastdata.lengthbytesField
cache_change.serializedPayload.lengthis equal todata.lengthField
cache_change.serializedPayload.max_sizeis greater than or equal todata.lengthContent of
cache_change.serializedPayload.datais the same asdata.data
-
virtual bool release_payload(CacheChange_t &cache_change) = 0
Release a serialized payload from a sample.
This method will be called when a cache change is removed from a history.
- Parameters
cache_change – [inout] Cache change to assign the payload to
- Returns
whether the operation succeeded or not
- Pre
Field
payload_ownerofcache_changeequals this
- Post
Field
payload_ownerofcache_changeisnullptr
-
virtual ~IPayloadPool() = default