XZ Utils 5.2.10
|
Output queue handling in multithreaded coding. More...
#include "common.h"
Data Structures | |
struct | lzma_outbuf |
Output buffer for a single thread. More... | |
struct | lzma_outq |
Functions | |
uint64_t | lzma_outq_memusage (uint64_t buf_size_max, uint32_t threads) |
Calculate the memory usage of an output queue. More... | |
lzma_ret | lzma_outq_init (lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads) |
Initialize an output queue. More... | |
void | lzma_outq_end (lzma_outq *outq, const lzma_allocator *allocator) |
Free the memory associated with the output queue. More... | |
lzma_outbuf * | lzma_outq_get_buf (lzma_outq *outq) |
Get a new buffer. More... | |
bool | lzma_outq_is_readable (const lzma_outq *outq) |
Test if there is data ready to be read. More... | |
lzma_ret | lzma_outq_read (lzma_outq *restrict outq, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_vli *restrict unpadded_size, lzma_vli *restrict uncompressed_size) |
Read finished data. More... | |
static bool | lzma_outq_has_buf (const lzma_outq *outq) |
Test if there is at least one buffer free. More... | |
static bool | lzma_outq_is_empty (const lzma_outq *outq) |
Test if the queue is completely empty. More... | |
Output queue handling in multithreaded coding.
uint64_t lzma_outq_memusage | ( | uint64_t | buf_size_max, |
uint32_t | threads | ||
) |
Calculate the memory usage of an output queue.
References get_options(), and LZMA_OK.
lzma_ret lzma_outq_init | ( | lzma_outq * | outq, |
const lzma_allocator * | allocator, | ||
uint64_t | buf_size_max, | ||
uint32_t | threads | ||
) |
Initialize an output queue.
outq | Pointer to an output queue. Before calling this function the first time, *outq should have been zeroed with memzero() so that this function knows that there are no previous allocations to free. |
allocator | Pointer to allocator or NULL |
buf_size_max | Maximum amount of data that a single buffer in the queue may need to store. |
threads | Number of buffers that may be in use concurrently. Note that more than this number of buffers will actually get allocated to improve performance when buffers finish out of order. |
void lzma_outq_end | ( | lzma_outq * | outq, |
const lzma_allocator * | allocator | ||
) |
Free the memory associated with the output queue.
lzma_outbuf * lzma_outq_get_buf | ( | lzma_outq * | outq | ) |
Get a new buffer.
lzma_outq_has_buf() must be used to check that there is a buffer available before calling lzma_outq_get_buf().
bool lzma_outq_is_readable | ( | const lzma_outq * | outq | ) |
Test if there is data ready to be read.
Call to this function must be protected with the same mutex that is used to protect lzma_outbuf.finished.
References lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_pos, lzma_outq::bufs_used, and lzma_outbuf::finished.
Referenced by wait_for_work().
lzma_ret lzma_outq_read | ( | lzma_outq *restrict | outq, |
uint8_t *restrict | out, | ||
size_t *restrict | out_pos, | ||
size_t | out_size, | ||
lzma_vli *restrict | unpadded_size, | ||
lzma_vli *restrict | uncompressed_size | ||
) |
Read finished data.
outq | Pointer to an output queue |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
unpadded_size | Unpadded Size from the Block encoder |
uncompressed_size | Uncompressed Size from the Block encoder |
|
inlinestatic |
Test if there is at least one buffer free.
This must be used before getting a new buffer with lzma_outq_get_buf().
References lzma_outq::bufs_allocated, and lzma_outq::bufs_used.
Referenced by wait_for_work().
|
inlinestatic |
Test if the queue is completely empty.
References lzma_outq::bufs_used.