help?> @lock
@lock l expr
Macro version of lock(f, l::AbstractLock) but with expr instead of f function. Expands
to:
lock(l)
try
expr
finally
unlock(l)
end
I’m not sure if this is a bug.
julia> r = Ref(0);
julia> x = r[]
0
julia> x
0
julia> l = ReentrantLock()
ReentrantLock() (unlocked)
julia> @lock(l, y = r[])
0
julia> y
ERROR: UndefVarError: `y` not defined in `Main`
julia> r = Ref(0);
julia> x = r[]
0
julia> x
0
julia> l = ReentrantLock()
ReentrantLock() (unlocked)
julia> lock(l)
julia> try
y = r[]
finally
unlock(l)
end
0
julia> y
ERROR: UndefVarError: `y` not defined in `Main`
Suggestion: check for spelling errors or missing imports.