From 98549d2149fed9cff8f1c483f219a5391949fb0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jofre=20Vall=C3=A8s?= Date: Wed, 17 Apr 2024 21:09:39 +0200 Subject: [PATCH] Reset __indexcounter if we pass the limit --- src/Utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils.jl b/src/Utils.jl index 5c9a1a1..e86e451 100644 --- a/src/Utils.jl +++ b/src/Utils.jl @@ -3,5 +3,5 @@ using Tenet const __indexcounter::Threads.Atomic{Int} = Threads.Atomic{Int}(1) currindex() = Tenet.letter(__indexcounter[]) -nextindex() = Tenet.letter(Threads.atomic_add!(__indexcounter, 1)) +nextindex() = (__indexcounter.value >= 135000) ? resetindex() : Tenet.letter(Threads.atomic_add!(__indexcounter, 1)) resetindex() = Tenet.letter(Threads.atomic_xchg!(__indexcounter, 1))