Lines Matching refs:bufPool
107 ZSTDMT_bufferPool* const bufPool = (ZSTDMT_bufferPool*)ZSTD_customCalloc( in ZSTDMT_createBufferPool() local
109 if (bufPool==NULL) return NULL; in ZSTDMT_createBufferPool()
110 if (ZSTD_pthread_mutex_init(&bufPool->poolMutex, NULL)) { in ZSTDMT_createBufferPool()
111 ZSTD_customFree(bufPool, cMem); in ZSTDMT_createBufferPool()
114 bufPool->bufferSize = 64 KB; in ZSTDMT_createBufferPool()
115 bufPool->totalBuffers = maxNbBuffers; in ZSTDMT_createBufferPool()
116 bufPool->nbBuffers = 0; in ZSTDMT_createBufferPool()
117 bufPool->cMem = cMem; in ZSTDMT_createBufferPool()
118 return bufPool; in ZSTDMT_createBufferPool()
121 static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool) in ZSTDMT_freeBufferPool() argument
124 DEBUGLOG(3, "ZSTDMT_freeBufferPool (address:%08X)", (U32)(size_t)bufPool); in ZSTDMT_freeBufferPool()
125 if (!bufPool) return; /* compatibility with free on NULL */ in ZSTDMT_freeBufferPool()
126 for (u=0; u<bufPool->totalBuffers; u++) { in ZSTDMT_freeBufferPool()
127 DEBUGLOG(4, "free buffer %2u (address:%08X)", u, (U32)(size_t)bufPool->bTable[u].start); in ZSTDMT_freeBufferPool()
128 ZSTD_customFree(bufPool->bTable[u].start, bufPool->cMem); in ZSTDMT_freeBufferPool()
130 ZSTD_pthread_mutex_destroy(&bufPool->poolMutex); in ZSTDMT_freeBufferPool()
131 ZSTD_customFree(bufPool, bufPool->cMem); in ZSTDMT_freeBufferPool()
135 static size_t ZSTDMT_sizeof_bufferPool(ZSTDMT_bufferPool* bufPool) in ZSTDMT_sizeof_bufferPool() argument
137 size_t const poolSize = sizeof(*bufPool) in ZSTDMT_sizeof_bufferPool()
138 + (bufPool->totalBuffers - 1) * sizeof(buffer_t); in ZSTDMT_sizeof_bufferPool()
141 ZSTD_pthread_mutex_lock(&bufPool->poolMutex); in ZSTDMT_sizeof_bufferPool()
142 for (u=0; u<bufPool->totalBuffers; u++) in ZSTDMT_sizeof_bufferPool()
143 totalBufferSize += bufPool->bTable[u].capacity; in ZSTDMT_sizeof_bufferPool()
144 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_sizeof_bufferPool()
153 static void ZSTDMT_setBufferSize(ZSTDMT_bufferPool* const bufPool, size_t const bSize) in ZSTDMT_setBufferSize() argument
155 ZSTD_pthread_mutex_lock(&bufPool->poolMutex); in ZSTDMT_setBufferSize()
157 bufPool->bufferSize = bSize; in ZSTDMT_setBufferSize()
158 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_setBufferSize()
183 static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* bufPool) in ZSTDMT_getBuffer() argument
185 size_t const bSize = bufPool->bufferSize; in ZSTDMT_getBuffer()
186 DEBUGLOG(5, "ZSTDMT_getBuffer: bSize = %u", (U32)bufPool->bufferSize); in ZSTDMT_getBuffer()
187 ZSTD_pthread_mutex_lock(&bufPool->poolMutex); in ZSTDMT_getBuffer()
188 if (bufPool->nbBuffers) { /* try to use an existing buffer */ in ZSTDMT_getBuffer()
189 buffer_t const buf = bufPool->bTable[--(bufPool->nbBuffers)]; in ZSTDMT_getBuffer()
191 bufPool->bTable[bufPool->nbBuffers] = g_nullBuffer; in ZSTDMT_getBuffer()
195 bufPool->nbBuffers, (U32)buf.capacity); in ZSTDMT_getBuffer()
196 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_getBuffer()
201 ZSTD_customFree(buf.start, bufPool->cMem); in ZSTDMT_getBuffer()
203 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_getBuffer()
207 void* const start = ZSTD_customMalloc(bSize, bufPool->cMem); in ZSTDMT_getBuffer()
225 static buffer_t ZSTDMT_resizeBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buffer) in ZSTDMT_resizeBuffer() argument
227 size_t const bSize = bufPool->bufferSize; in ZSTDMT_resizeBuffer()
229 void* const start = ZSTD_customMalloc(bSize, bufPool->cMem); in ZSTDMT_resizeBuffer()
246 static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buf) in ZSTDMT_releaseBuffer() argument
250 ZSTD_pthread_mutex_lock(&bufPool->poolMutex); in ZSTDMT_releaseBuffer()
251 if (bufPool->nbBuffers < bufPool->totalBuffers) { in ZSTDMT_releaseBuffer()
252 bufPool->bTable[bufPool->nbBuffers++] = buf; /* stored for later use */ in ZSTDMT_releaseBuffer()
254 (U32)buf.capacity, (U32)(bufPool->nbBuffers-1)); in ZSTDMT_releaseBuffer()
255 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_releaseBuffer()
258 ZSTD_pthread_mutex_unlock(&bufPool->poolMutex); in ZSTDMT_releaseBuffer()
261 ZSTD_customFree(buf.start, bufPool->cMem); in ZSTDMT_releaseBuffer()
643 ZSTDMT_bufferPool* bufPool; /* Thread-safe - used by mtctx and (all) workers */ member
679 dstBuff = ZSTDMT_getBuffer(job->bufPool); in ZSTDMT_compressionJob()
837 ZSTDMT_bufferPool* bufPool; member
947 mtctx->bufPool = ZSTDMT_createBufferPool(BUF_POOL_MAX_NB_BUFFERS(nbWorkers), cMem); in ZSTDMT_createCCtx_advanced_internal()
952 …if (!mtctx->factory | !mtctx->jobs | !mtctx->bufPool | !mtctx->cctxPool | !mtctx->seqPool | initEr… in ZSTDMT_createCCtx_advanced_internal()
985 ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff); in ZSTDMT_releaseAllJobResources()
1019 ZSTDMT_freeBufferPool(mtctx->bufPool); in ZSTDMT_freeCCtx()
1035 + ZSTDMT_sizeof_bufferPool(mtctx->bufPool) in ZSTDMT_sizeof_CCtx()
1050 mtctx->bufPool = ZSTDMT_expandBufferPool(mtctx->bufPool, BUF_POOL_MAX_NB_BUFFERS(nbWorkers)); in ZSTDMT_resize()
1051 if (mtctx->bufPool == NULL) return ERROR(memory_allocation); in ZSTDMT_resize()
1283 ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(mtctx->targetSectionSize)); in ZSTDMT_initCStream_internal()
1339 job->dstBuff = ZSTDMT_getBuffer(job->bufPool); in ZSTDMT_writeLastEmptyBlock()
1377 mtctx->jobs[jobID].bufPool = mtctx->bufPool; in ZSTDMT_createCompressionJob()
1501 ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[wJobID].dstBuff); in ZSTDMT_flushProduced()