I have created a package that uses a spin lock and I have declared this as module constant (example shown below). Since Julia compiles the package, it will declare the constant only once. Will this cause any unexpected issues? If it is safe, can I use Reentract Lock, Thread Condition in similar way?
module Test
import Base.Threads: SpinLock, lock, unlock, trylock, islocked, wait, notify
const spin_lock = SpinLock()
function f1()
lock(spin_lock) do
# some work
end
end
function f2()
lock(spin_lock) do
# some work
end
end
end