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

Make API globals thread safe using atomics #222

Merged
merged 1 commit into from
Nov 25, 2021
Merged

Make API globals thread safe using atomics #222

merged 1 commit into from
Nov 25, 2021

Commits on Nov 23, 2021

  1. Make API globals thread safe using atomics

    While the GIL is held when the API pointer is updated, this can still race with
    other threads checking the current value of the API pointer (without holding the
    GIL) and should therefore using atomics.
    
    The loads and stores are performed using acquire-release semantics as we want to
    dereference the pointer and hence any stores to the referenced memory need to be
    visible to us.
    
    The get function should also be unsafe as the offset it uses cannot be verified
    which might create an invalid pointer invoking undefined behaviour as per the
    contract of pointer::offset.
    
    Finally, the initialization code is moved into a separate cold function to
    improve code locality for the fast path.
    adamreichold committed Nov 23, 2021
    Configuration menu
    Copy the full SHA
    a0ecc3f View commit details
    Browse the repository at this point in the history