XZ Utils 5.4.1
|
Multithreaded .xz Stream encoder. More...
#include "filter_encoder.h"
#include "easy_preset.h"
#include "block_encoder.h"
#include "block_buffer_encoder.h"
#include "index_encoder.h"
#include "outqueue.h"
Data Structures | |
struct | worker_thread_s |
struct | lzma_stream_coder_s |
Macros | |
#define | BLOCK_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX) |
Typedefs | |
typedef struct lzma_stream_coder_s | lzma_stream_coder |
typedef struct worker_thread_s | worker_thread |
Enumerations | |
enum | worker_state { THR_IDLE , THR_RUN , THR_EXIT , THR_IDLE , THR_RUN , THR_FINISH , THR_STOP , THR_EXIT } |
Functions | |
static void | worker_error (worker_thread *thr, lzma_ret ret) |
Tell the main thread that something has gone wrong. More... | |
static worker_state | worker_encode (worker_thread *thr, size_t *out_pos, worker_state state) |
static MYTHREAD_RET_TYPE | worker_start (void *thr_ptr) |
static void | threads_stop (lzma_stream_coder *coder, bool wait_for_threads) |
Make the threads stop but not exit. Optionally wait for them to stop. More... | |
static void | threads_end (lzma_stream_coder *coder, const lzma_allocator *allocator) |
static lzma_ret | initialize_new_thread (lzma_stream_coder *coder, const lzma_allocator *allocator) |
Initialize a new worker_thread structure and create a new thread. More... | |
static lzma_ret | get_thread (lzma_stream_coder *coder, const lzma_allocator *allocator) |
static lzma_ret | stream_encode_in (lzma_stream_coder *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, lzma_action action) |
static bool | wait_for_work (lzma_stream_coder *coder, mythread_condtime *wait_abs, bool *has_blocked, bool has_input) |
static lzma_ret | stream_encode_mt (void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) |
static void | stream_encoder_mt_end (void *coder_ptr, const lzma_allocator *allocator) |
static lzma_ret | stream_encoder_mt_update (void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters, const lzma_filter *reversed_filters lzma_attribute((__unused__))) |
static lzma_ret | get_options (const lzma_mt *options, lzma_options_easy *opt_easy, const lzma_filter **filters, uint64_t *block_size, uint64_t *outbuf_size_max) |
static void | get_progress (void *coder_ptr, uint64_t *progress_in, uint64_t *progress_out) |
static lzma_ret | stream_encoder_mt_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_mt *options) |
lzma_ret | lzma_stream_encoder_mt (lzma_stream *strm, const lzma_mt *options) |
Initialize multithreaded .xz Stream encoder. More... | |
uint64_t | lzma_stream_encoder_mt_memusage (const lzma_mt *options) |
Calculate approximate memory usage of multithreaded .xz encoder. More... | |
Multithreaded .xz Stream encoder.
#define BLOCK_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX) |
Maximum supported block size. This makes it simpler to prevent integer overflows if we are given unusually large block size.
enum worker_state |
|
static |
Tell the main thread that something has gone wrong.
|
static |
Make the threads stop but not exit. Optionally wait for them to stop.
References worker_thread::state, THR_IDLE, THR_STOP, lzma_stream_coder::threads, and lzma_stream_coder::threads_initialized.
|
static |
Stop the threads and free the resources associated with them. Wait until the threads have exited.
|
static |
Initialize a new worker_thread structure and create a new thread.
|
static |
Wait until more input can be consumed, more output can be read, or an optional timeout is reached.
References LZMA_OK, lzma_outq_has_buf(), lzma_outq_is_readable(), lzma_stream_coder::outq, lzma_stream_coder::thread_error, lzma_stream_coder::threads_free, and lzma_stream_coder::timeout.
|
static |
Options handling for lzma_stream_encoder_mt_init() and lzma_stream_encoder_mt_memusage()
References lzma_mt::block_size, BLOCK_SIZE_MAX, lzma_mt::filters, lzma_options_easy::filters, filters, lzma_mt::flags, lzma_easy_preset(), LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_THREADS_MAX, lzma_mt::preset, and lzma_mt::threads.
Referenced by lzma_stream_encoder_mt_memusage().
lzma_ret lzma_stream_encoder_mt | ( | lzma_stream * | strm, |
const lzma_mt * | options | ||
) |
Initialize multithreaded .xz Stream encoder.
This provides the functionality of lzma_easy_encoder() and lzma_stream_encoder() as a single function for multithreaded use.
The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be added in the future.
strm | Pointer to properly prepared lzma_stream |
options | Pointer to multithreaded compression options |
References lzma_next_strm_init.
uint64_t lzma_stream_encoder_mt_memusage | ( | const lzma_mt * | options | ) |
Calculate approximate memory usage of multithreaded .xz encoder.
Since doing the encoding in threaded mode doesn't affect the memory requirements of single-threaded decompressor, you can use lzma_easy_decoder_memusage(options->preset) or lzma_raw_decoder_memusage(options->filters) to calculate the decompressor memory requirements.
options | Compression options |
References filters, get_options(), and LZMA_OK.