Skip to content

assert_once_ever!() macro #7748

Closed
Closed
@bblum

Description

@bblum

Some places in the task code are commented with "only one task should ever do this". Now that we have unsafe global variables, we can implement a safe convenience macro that can assert this at runtime instead of at comment-time.

It should expand to something like:

unsafe {
    static mut __gensymed__thing_already_happened: bool = false;
    // "double-check locking" to avoid doing an xchg all the time
    if __gensymed__thing_already_happened == false {
        if atomic_xchg(&mut __gensymed__thing_already_happened, true, Relaxed) == true {
            fail!($provided_message);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyA-syntaxextArea: Syntax extensionsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions