From e7b424d267a34803db8d92a3515528be2ed45abd Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Fri, 14 Dec 2012 20:13:32 +0200 Subject: Make the progress indicator smooth in threaded mode. This adds lzma_get_progress() to liblzma and takes advantage of it in xz. lzma_get_progress() collects progress information from the thread-specific structures so that fairly accurate progress information is available to applications. Adding a new function seemed to be a better way than making the information directly available in lzma_stream (like total_in and total_out are) because collecting the information requires locking mutexes. It's waste of time to do it more often than the up to date information is actually needed by an application. --- src/liblzma/common/common.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/liblzma/common/common.h') diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h index 86c5f02c..b71254d0 100644 --- a/src/liblzma/common/common.h +++ b/src/liblzma/common/common.h @@ -155,6 +155,11 @@ struct lzma_next_coder_s { /// lzma_next_coder.coder. lzma_end_function end; + /// Pointer to a function to get progress information. If this is NULL, + /// lzma_stream.total_in and .total_out are used instead. + void (*get_progress)(lzma_coder *coder, + uint64_t *progress_in, uint64_t *progress_out); + /// Pointer to function to return the type of the integrity check. /// Most coders won't support this. lzma_check (*get_check)(const lzma_coder *coder); @@ -180,6 +185,7 @@ struct lzma_next_coder_s { .id = LZMA_VLI_UNKNOWN, \ .code = NULL, \ .end = NULL, \ + .get_progress = NULL, \ .get_check = NULL, \ .memconfig = NULL, \ .update = NULL, \ -- cgit v1.2.3