xz: Minor internal changes to handling of --threads.

Now it always defaults to one thread. Maybe this
will change again if a threading method is added
that doesn't affect memory usage.
This commit is contained in:
Lasse Collin 2011-04-09 15:11:13 +03:00
parent 9edd6ee895
commit 335fe260a8
3 changed files with 18 additions and 19 deletions

View File

@ -179,8 +179,8 @@ parse_real(args_info *args, int argc, char **argv)
break; break;
case 'T': case 'T':
hardware_threadlimit_set(str_to_uint64( hardware_threads_set(str_to_uint64("threads",
"threads", optarg, 0, UINT32_MAX)); optarg, 0, LZMA_THREADS_MAX));
break; break;
// --version // --version

View File

@ -14,9 +14,9 @@
#include "tuklib_cpucores.h" #include "tuklib_cpucores.h"
/// Maximum number of free *coder* threads. This can be set with /// Maximum number of worker threads. This can be set with
/// the --threads=NUM command line option. /// the --threads=NUM command line option.
static uint32_t threadlimit; static uint32_t threads_max = 1;
/// Memory usage limit for compression /// Memory usage limit for compression
static uint64_t memlimit_compress; static uint64_t memlimit_compress;
@ -29,15 +29,16 @@ static uint64_t total_ram;
extern void extern void
hardware_threadlimit_set(uint32_t new_threadlimit) hardware_threads_set(uint32_t n)
{ {
if (new_threadlimit == 0) { if (n == 0) {
// The default is the number of available CPU cores. // Automatic number of threads was requested.
threadlimit = tuklib_cpucores(); // Use the number of available CPU cores.
if (threadlimit == 0) threads_max = tuklib_cpucores();
threadlimit = 1; if (threads_max == 0)
threads_max = 1;
} else { } else {
threadlimit = new_threadlimit; threads_max = n;
} }
return; return;
@ -45,9 +46,9 @@ hardware_threadlimit_set(uint32_t new_threadlimit)
extern uint32_t extern uint32_t
hardware_threadlimit_get(void) hardware_threads_get(void)
{ {
return threadlimit; return threads_max;
} }
@ -139,6 +140,5 @@ hardware_init(void)
// Set the defaults. // Set the defaults.
hardware_memlimit_set(0, true, true, false); hardware_memlimit_set(0, true, true, false);
hardware_threadlimit_set(0);
return; return;
} }

View File

@ -15,12 +15,11 @@
extern void hardware_init(void); extern void hardware_init(void);
/// Set custom value for maximum number of coder threads. /// Set the maximum number of worker threads.
extern void hardware_threadlimit_set(uint32_t threadlimit); extern void hardware_threads_set(uint32_t threadlimit);
/// Get the maximum number of coder threads. Some additional helper threads /// Get the maximum number of worker threads.
/// are allowed on top of this). extern uint32_t hardware_threads_get(void);
extern uint32_t hardware_threadlimit_get(void);
/// Set the memory usage limit. There are separate limits for compression /// Set the memory usage limit. There are separate limits for compression