mirror of
https://github.com/facebook/zstd
synced 2026-08-22 22:32:07 -04:00
minor : update streaming_compression example
display a warning when requesting multi-threading while linking to a library that doesn't support multi-threading.
This commit is contained in:
parent
e256e43274
commit
6ec18aed31
1 changed files with 8 additions and 2 deletions
|
|
@ -42,7 +42,13 @@ static void compressFile_orDie(const char* fname, const char* outName, int cLeve
|
||||||
*/
|
*/
|
||||||
CHECK_ZSTD( ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, cLevel) );
|
CHECK_ZSTD( ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, cLevel) );
|
||||||
CHECK_ZSTD( ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1) );
|
CHECK_ZSTD( ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1) );
|
||||||
ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, nbThreads);
|
if (nbThreads > 1) {
|
||||||
|
size_t const r = ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, nbThreads);
|
||||||
|
if (ZSTD_isError(r)) {
|
||||||
|
fprintf (stderr, "Note: the linked libzstd library doesn't support multithreading. "
|
||||||
|
"Reverting to single-thread mode. \n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This loop read from the input file, compresses that entire chunk,
|
/* This loop read from the input file, compresses that entire chunk,
|
||||||
* and writes all output produced to the output file.
|
* and writes all output produced to the output file.
|
||||||
|
|
@ -117,7 +123,7 @@ int main(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
int cLevel = 1;
|
int cLevel = 1;
|
||||||
int nbThreads = 4;
|
int nbThreads = 1;
|
||||||
|
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
cLevel = atoi (argv[2]);
|
cLevel = atoi (argv[2]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue