Skip to content

Thread safe initialization #13806

@maia-s

Description

@maia-s

There's a few functions in SDL that are documented to be safe to call from any thread which just check a static variable and then do initialization if it's not been set. For example SDL_GetTicks/NS, all the cpu feature functions, and (although not documented to be thread safe) SDL_GetBasePath, SDL_IsMainThread (doesn't init but doesn't use atomic) etc. These should probably use SDL_InitState or at least an atomic? I can make a PR, but first I wanted to check if there's a reason they're not doing that already

(ofc GetTicks has to be fast and atomics are slow, but in that case i think it's probably ok to just check the static and use atomics only for initialization, since SDL's atomics do full sync. tho relaxed atomic would be better for platforms that can do that fast)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions