Skip to content

at-atomic macro as alternative to disable_sigint() #12309

@kmsquire

Description

@kmsquire

While working on VideoIO, I was unaware of disable_sigint, and created a macro which disables interrupts around sections of code:

macro atomic(code)
    quote
        Base.sigatomic_begin()
        ret = ($code)
        Base.sigatomic_end()
        ret
    end
end

Even after discovering disable_sigint, I like this a little better, especially for single ccalls (or in the case of VideoIO, wrapped ccalls):

@atomic av_freep(c)  # function which wraps ccall((:av_freep,libavutil),Void,(Ptr{Void},),ptr)

Is there interest in having this in Base? If so, I'll submit a PR.

Cc: @stevengj

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