mirror of
https://github.com/vasi/pixz
synced 2024-11-16 21:26:04 +00:00
Allow capping the number of threads
This commit is contained in:
parent
cc4b76cb0b
commit
1799c4e8f1
5
common.c
5
common.c
@ -333,6 +333,8 @@ queue_t *gPipelineStartQ = NULL,
|
||||
*gPipelineSplitQ = NULL,
|
||||
*gPipelineMergeQ = NULL;
|
||||
|
||||
size_t gPipelineProcessMax = 0;
|
||||
|
||||
pipeline_data_free_t gPLFreer = NULL;
|
||||
pipeline_split_t gPLSplit = NULL;
|
||||
pipeline_process_t gPLProcess = NULL;
|
||||
@ -367,6 +369,9 @@ void pipeline_create(
|
||||
gPLMergedItems = NULL;
|
||||
|
||||
gPLProcessCount = num_threads();
|
||||
if (gPipelineProcessMax > 0 && gPipelineProcessMax < gPLProcessCount)
|
||||
gPLProcessCount = gPipelineProcessMax;
|
||||
|
||||
gPLProcessThreads = malloc(gPLProcessCount * sizeof(pthread_t));
|
||||
for (size_t i = 0; i < (int)(gPLProcessCount * 2 + 3); ++i) {
|
||||
// create blocks, including a margin of error
|
||||
|
12
pixz.c
12
pixz.c
@ -55,7 +55,9 @@ int main(int argc, char **argv) {
|
||||
char *ipath = NULL, *opath = NULL;
|
||||
|
||||
int ch;
|
||||
while ((ch = getopt(argc, argv, "dxli:o:tvh0123456789")) != -1) {
|
||||
char *optend;
|
||||
long optint;
|
||||
while ((ch = getopt(argc, argv, "dxli:o:tvhp:0123456789")) != -1) {
|
||||
switch (ch) {
|
||||
case 'd': op = OP_READ; break;
|
||||
case 'x': op = OP_EXTRACT; break;
|
||||
@ -63,7 +65,13 @@ int main(int argc, char **argv) {
|
||||
case 'i': ipath = optarg; break;
|
||||
case 'o': opath = optarg; break;
|
||||
case 't': tar = false; break;
|
||||
case 'h': usage(NULL);
|
||||
case 'h': usage(NULL); break;
|
||||
case 'p':
|
||||
optint = strtol(optarg, &optend, 10);
|
||||
if (optint < 0 || *optend)
|
||||
usage("Need a non-negative integer argument to -p");
|
||||
gPipelineProcessMax = optint;
|
||||
break;
|
||||
default:
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
level = ch - '0';
|
||||
|
Loading…
Reference in New Issue
Block a user