Skip to content

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

@NHDaly

Description

@NHDaly

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions