refactor(compress): move job table init policy to Rust
Keep job table allocation, private synchronization callbacks, and initialization-failure cleanup in one Rust adapter. The C wrapper now only supplies pthread/object callbacks, preserving rounded capacity and the destroy-before-custom-free ordering; table expansion reuses the same path. Test Plan: - rustfmt --check --edition 2021 rust/src/zstdmt_compress.rs - git diff --check and git diff --cached --check - Static inspection only; cargo, make, tests, fuzzers, and native/heavy commands were not run under the global 40 GiB cap.
This commit is contained in:
@@ -666,6 +666,9 @@ typedef int (*ZSTDMT_jobTableInitFn)(void* jobTable, unsigned nbJobs,
|
||||
size_t jobSize);
|
||||
typedef void (*ZSTDMT_jobTableDestroyFn)(void* jobTable, unsigned nbJobs,
|
||||
size_t jobSize);
|
||||
void* ZSTDMT_rust_createJobsTable(
|
||||
unsigned* nbJobsPtr, size_t jobSize, ZSTD_customMem cMem,
|
||||
ZSTDMT_jobTableInitFn initSync, ZSTDMT_jobTableDestroyFn destroySync);
|
||||
size_t ZSTDMT_rust_expandJobsTable(
|
||||
void** jobTablePtr, unsigned* jobIDMaskPtr, unsigned nbWorkers,
|
||||
size_t jobSize, ZSTD_customMem cMem,
|
||||
@@ -1753,14 +1756,9 @@ void ZSTDMT_job_table_destroy_sync(void* jobTable, unsigned nbJobs, size_t jobSi
|
||||
* update *nbJobsPtr to next power of 2 value, as size of table */
|
||||
static ZSTDMT_jobDescription* ZSTDMT_createJobsTable(U32* nbJobsPtr, ZSTD_customMem cMem)
|
||||
{
|
||||
ZSTDMT_jobDescription* const jobTable = (ZSTDMT_jobDescription*)
|
||||
ZSTDMT_rust_job_table_create(nbJobsPtr, sizeof(ZSTDMT_jobDescription), cMem);
|
||||
if (jobTable == NULL) return NULL;
|
||||
if (ZSTDMT_job_table_init_sync(jobTable, *nbJobsPtr, sizeof(*jobTable)) != 0) {
|
||||
ZSTDMT_freeJobsTable(jobTable, *nbJobsPtr, cMem);
|
||||
return NULL;
|
||||
}
|
||||
return jobTable;
|
||||
return (ZSTDMT_jobDescription*) ZSTDMT_rust_createJobsTable(
|
||||
nbJobsPtr, sizeof(ZSTDMT_jobDescription), cMem,
|
||||
ZSTDMT_job_table_init_sync, ZSTDMT_job_table_destroy_sync);
|
||||
}
|
||||
|
||||
static size_t ZSTDMT_expandJobsTable (ZSTDMT_CCtx* mtctx, U32 nbWorkers) {
|
||||
|
||||
Reference in New Issue
Block a user