I would write this as
using OhMyThreads
outputs = @tasks for j in some_iterable
@set collect=true # makes this into a `map`-like operation
@local ds = mutable_datastructure() # Creates 1-instance of your mutable data structure per task
computation!(ds, j)
end
For what it’s worth, what you were doing was incorrect long before v1.12, it’s just that it broke even more with 1.12. There’s a blogpost about this here that explains why uses of threadid
like this cause race conditions. PSA: Thread-local state is no longer recommended. It should really be updated to mention OhMyThreads.jl though