Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Base.@lock macro, which avoids allocations for locked blocks, introduced in julia v1.3 #762

Open
NHDaly opened this issue Jan 2, 2022 · 0 comments

Comments

@NHDaly
Copy link
Member

NHDaly commented Jan 2, 2022

X-Ref:

Lets add @lock to Compat.jl so everyone can use this

Originally posted by @omus in JuliaTime/TimeZones.jl#356 (comment)

Ref: JuliaLang/julia#36441 and JuliaLang/julia#39588


This would look something like this:

if VERSION >= v"1.3-"
    using Base: @lock
else
    macro lock(l, e)
        quote
            ll = $(esc(l));
            $lock(ll);
            try
                $(esc(e))
            finally
                $unlock(ll)
            end
        end
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant