add a cond_broadcast after resize

to make sure all threads (notably newly available threads)
get awaken to immediately process potential items in the queue.
dev
Yann Collet 2018-06-21 18:04:58 -07:00
parent 818e72b4d5
commit 243cd9d8bb
1 changed files with 7 additions and 4 deletions

View File

@ -225,13 +225,16 @@ static POOL_ctx* POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
* note : starting context is considered consumed. */
POOL_ctx* POOL_resize(POOL_ctx* ctx, size_t numThreads)
{
POOL_ctx* newCtx;
if (ctx==NULL) return NULL;
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
newCtx = POOL_resize_internal(ctx, numThreads);
{ POOL_ctx* const newCtx = POOL_resize_internal(ctx, numThreads);
if (newCtx!=ctx) {
POOL_free(ctx);
return newCtx;
} }
ZSTD_pthread_cond_broadcast(&ctx->queuePopCond);
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
if (newCtx!=ctx) POOL_free(ctx);
return newCtx;
return ctx;
}
/**