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
size
will 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
writerGUID
andsequenceNumber
ofcache_change
are 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_owner
equals thisField
serializedPayload.data
points to a buffer of at leastsize
bytesField
serializedPayload.max_size
is 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
data
anddata_owner
are 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.data
to 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_payload
will be called to indicate that the reception thread is not using the payload anymore.Warning
data_owner
can only be changed fromnullptr
tothis
. If a value different fromnullptr
is received it should be left unchanged.Warning
data
fields can only be changed whendata_owner
isnullptr
. If a value different fromnullptr
is received all fields indata
should 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.writerGUID
is notunknown
Field
cache_change.sequenceNumber
is notunknown
- Post
Field
cache_change.payload_owner
equals thisField
cache_change.serializedPayload.data
points to a buffer of at leastdata.length
bytesField
cache_change.serializedPayload.length
is equal todata.length
Field
cache_change.serializedPayload.max_size
is greater than or equal todata.length
Content of
cache_change.serializedPayload.data
is 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_owner
ofcache_change
equals this
- Post
Field
payload_owner
ofcache_change
isnullptr
-
virtual ~IPayloadPool() = default