Is there any way to make Julia properly infer types in this code:
function f() x = 0 l = Threads.SpinLock() Threads.@threads for i in 1:Threads.nthreads() Threads.lock(l) x = x + i Threads.unlock(l) end x end
@code_warntype f() indicates that
x is boxed because
@threads creates a closure. I tried
let trick, but it does not work in this case.
Does anyone have some advice?