Rizin
unix-like reverse engineering framework and cli tools
|
Output queue handling in multithreaded coding. More...
#include "common.h"
Go to the source code of this file.
Classes | |
struct | lzma_outbuf |
Output buffer for a single thread. More... | |
struct | lzma_outq |
Output queue handling in multithreaded coding.
Definition in file outqueue.h.
void lzma_outq_end | ( | lzma_outq * | outq, |
const lzma_allocator * | allocator | ||
) |
Free the memory associated with the output queue.
Definition at line 101 of file outqueue.c.
References allocator, lzma_outq::bufs, lzma_outq::bufs_mem, lzma_free(), and NULL.
Referenced by lzma_outq_init(), and stream_encoder_mt_end().
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().
Definition at line 114 of file outqueue.c.
References assert(), lzma_outbuf::buf, lzma_outq::buf_size_max, lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_mem, lzma_outq::bufs_pos, and lzma_outq::bufs_used.
Referenced by get_thread().
Test if there is at least one buffer free.
This must be used before getting a new buffer with lzma_outq_get_buf().
Definition at line 145 of file outqueue.h.
References lzma_outq::bufs_allocated, and lzma_outq::bufs_used.
Referenced by get_thread(), and wait_for_work().
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. |
Definition at line 57 of file outqueue.c.
References allocator, lzma_outq::buf_size_max, lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_mem, lzma_outq::bufs_pos, lzma_outq::bufs_used, get_options(), lzma_alloc(), LZMA_MEM_ERROR, LZMA_OK, lzma_outq_end(), NULL, lzma_outq::read_pos, return_if_error, SIZE_MAX, and threads.
Referenced by stream_encoder_mt_init().
Test if the queue is completely empty.
Definition at line 153 of file outqueue.h.
References lzma_outq::bufs_used.
Referenced by stream_encode_mt().
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.
Definition at line 136 of file outqueue.c.
References lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_pos, lzma_outq::bufs_used, lzma_outbuf::finished, and i.
Referenced by wait_for_work().
Calculate the memory usage of an output queue.
Definition at line 42 of file outqueue.c.
References get_options(), LZMA_OK, threads, and UINT64_MAX.
Referenced by LZMA_API().
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 |
Definition at line 147 of file outqueue.c.
References i, lzma_bufcpy(), LZMA_OK, LZMA_STREAM_END, out, out_pos, uncompressed_size, and unpadded_size.
Referenced by stream_encode_mt().