XZ Utils
5.2.2
|
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_coder_s |
Macros | |
#define | BLOCK_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX) |
Typedefs | |
typedef struct worker_thread_s | worker_thread |
Enumerations | |
enum | worker_state { 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, worker_state state) |
static MYTHREAD_RET_TYPE | worker_start (void *thr_ptr) |
static void | threads_stop (lzma_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_coder *coder, const lzma_allocator *allocator) |
static lzma_ret | initialize_new_thread (lzma_coder *coder, const lzma_allocator *allocator) |
Initialize a new worker_thread structure and create a new thread. More... | |
static lzma_ret | get_thread (lzma_coder *coder, const lzma_allocator *allocator) |
static lzma_ret | stream_encode_in (lzma_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_coder *coder, mythread_condtime *wait_abs, bool *has_blocked, bool has_input) |
static lzma_ret | stream_encode_mt (lzma_coder *coder, 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 (lzma_coder *coder, const lzma_allocator *allocator) |
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 (lzma_coder *coder, 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.
Referenced by get_options().
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 THR_IDLE, THR_STOP, lzma_coder_s::threads, and lzma_coder_s::threads_initialized.
|
static |
Stop the threads and free the resources associated with them. Wait until the threads have exited.
References THR_EXIT, worker_thread_s::thread_id, lzma_coder_s::threads, and lzma_coder_s::threads_initialized.
|
static |
Initialize a new worker_thread structure and create a new thread.
References worker_thread_s::allocator, worker_thread_s::block_encoder, lzma_coder_s::block_size, worker_thread_s::coder, worker_thread_s::in, lzma_alloc(), LZMA_MEM_ERROR, LZMA_NEXT_CODER_INIT, worker_thread_s::progress_in, worker_thread_s::progress_out, THR_IDLE, worker_thread_s::thread_id, lzma_coder_s::threads, and lzma_coder_s::threads_initialized.
|
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_coder_s::outq, lzma_coder_s::thread_error, lzma_coder_s::threads_free, and lzma_coder_s::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_options_easy::filters, lzma_mt::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_outq_memusage(), and 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.