From 45d68f9f6d832095fb15139d43e55f905aee1b33 Mon Sep 17 00:00:00 2001 From: marekkokot Date: Thu, 18 Jan 2024 22:55:34 +0100 Subject: [PATCH] fix for multiple kmc instances in a single process --- kmc_core/small_sort.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kmc_core/small_sort.h b/kmc_core/small_sort.h index 10215f2..800e295 100644 --- a/kmc_core/small_sort.h +++ b/kmc_core/small_sort.h @@ -153,13 +153,25 @@ class CSmallSort { static void Adjust(uint32 max_small_size = 256) { + static bool is_adjusted = false; + if (is_adjusted) + return; + + static std::mutex mtx; + std::lock_guard lck(mtx); + if (is_adjusted) + return; + PrepareArray(); EvaluateAlgorithms(max_small_size); SmoothTimes(); SelectBestSorters(); ReleaseArray(); + + is_adjusted = true; } + static void Sort(CKmer *ptr, uint32 size) { sorters[size](ptr, size);