acl/decompression/database/database_streamer.h¶
#include "acl/decompression/database/database_streamer.h"
The interface that streams the bulk data of a compressed database in and out.
streaming_action¶
enum class streaming_action
{
stream_in,
stream_out,
};
Enum representing a streaming action.
| Value | Description |
|---|---|
stream_in |
Load the chunks of a tier into memory. |
stream_out |
Release the chunks of a tier from memory. |
streaming_request¶
struct streaming_request
A streaming request.
streaming_request::action¶
streaming_action action = streaming_action::stream_in;
The action to do.
streaming_request::tier¶
quality_tier tier = quality_tier::highest_importance;
The tier to stream. The highest tier marks the request as invalid since we never stream the highest tier.
streaming_request::first_chunk_index¶
uint32_t first_chunk_index = 0;
The index of the first chunk to stream.
streaming_request::num_streaming_chunks¶
uint32_t num_streaming_chunks = 0;
The number of chunks to stream.
streaming_request::generation_id¶
uint32_t generation_id = 0;
A value that changes each time the streamer reuses this request, to detect a stale request ID.
streaming_request::is_valid¶
bool is_valid() const
Returns true if the request is in use.
streaming_request::reset¶
void reset()
Marks the request as not in use.
streaming_request_id¶
struct streaming_request_id
A streaming request ID
The internal value is an implementation detail.
streaming_request_id::value¶
uint64_t value;
Opaque value.
streaming_request_id::is_valid¶
bool is_valid() const
Returns true if the ID is not the invalid ID.
k_invalid_streamer_request_id¶
streaming_request_id k_invalid_streamer_request_id = { ~0ULL };
An invalid streaming request ID.
database_streamer¶
class database_streamer
The base class for database streamers.
Streamer implementations are responsible for allocating/freeing the bulk data as well as streaming the data in/out. Streaming in is safe from any thread but streaming out cannot happen while decompression is in progress otherwise the behavior is undefined. A single streamer instance can be shared between all quality tiers of a database. Streamers cannot be shared by multiple databases. A streamer implementation must also provide a list of streaming requests to use and recycle. A proper implementation should consider how many requests it needs.
database_streamer::~database_streamer¶
virtual ~database_streamer() = default
Streamer destructor.
database_streamer::is_initialized¶
virtual bool is_initialized() const =0
Returns true if the streamer is initialized.
database_streamer::get_bulk_data¶
virtual const uint8_t* get_bulk_data(quality_tier tier) const =0
Returns a valid pointer to the bulk data used to decompress from for the specified quality tier. Note that the pointer will not be used until after the first successful stream in request is completed. As such, it is safe to allocate the bulk data when the first stream in request happens.
database_streamer::stream_in¶
virtual void stream_in(
uint32_t offset,
uint32_t size,
bool can_allocate_bulk_data,
quality_tier tier,
streaming_request_id request_id) = 0
Called when we request some data to be streamed in. Only one stream in/out request can be in flight at a time per quality tier. Streaming in animation data can be done while animations are decompressing (async).
The offset into the bulk data and the size in bytes to stream in are provided as arguments. On the first stream in request, the bulk data can be allocated but its pointer cannot change with subsequent stream in requests until everything has been streamed out. Once the streaming request has been fulfilled (sync or async), call complete(..) or cancel(..) with the provided request ID.
database_streamer::stream_out¶
virtual void stream_out(
uint32_t offset,
uint32_t size,
bool can_deallocate_bulk_data,
quality_tier tier,
streaming_request_id request_id) = 0
Called when we request some data to be streamed out. Only one stream in/out request can be in flight at a time per quality tier. Streaming out animation data cannot be done while animations are decompressing. Doing so will result in undefined behavior as the data could be in use while we stream it out.
The offset into the bulk data and the size in bytes to stream out are provided as arguments. On the last stream out request, the bulk data can be deallocated. It will be allocated again if the data streams back in. Once the streaming request has been fulfilled (sync or async), call complete(..) or cancel(..) with the provided request ID.
A stream out request CANNOT be canceled!
database_streamer::complete¶
void complete(streaming_request_id request_id)
Signifies that the streamer has completed this streaming request successfully. The bulk data must be allocated and ready to use.
database_streamer::cancel¶
void cancel(streaming_request_id request_id)
Signifies that the streamer will not complete this streaming request.