|
XZ Utils
5.2.2
|
Output queue handling in multithreaded coding. More...
#include "outqueue.h"Macros | |
| #define | BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2) |
Functions | |
| static lzma_ret | get_options (uint64_t *bufs_alloc_size, uint32_t *bufs_count, uint64_t buf_size_max, uint32_t threads) |
| 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... | |
Output queue handling in multithreaded coding.
| #define BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2) |
This is to ease integer overflow checking: We may allocate up to 2 * LZMA_THREADS_MAX buffers and we need some extra memory for other data structures (that's the second /2).
| 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 |
1.8.13