Skip to content

Commit

Permalink
pythongh-112529: Use atomic operations for gcstate->collecting
Browse files Browse the repository at this point in the history
The `collecting` field in `GCState` is used to prevent overlapping garbage
collections within the same interpreter. This is updated to use atomic
operations in order to be thread-safe in `--disable-gil` builds.

The GC code is refactored a bit to support this. More of the logic is pushed
down to `gc_collect_main()` so that we can safely order the logic setting
`collecting`, the selection of the generation, and the invocation of callbacks
with respect to the atomic operations and the (future) stop-the-world pauses.

The change uses atomic operations for both `--disable-gil` and the default
build (with the GIL) to avoid extra `#ifdef` guards and ease the maintenance
burden.
  • Loading branch information
colesbury committed Nov 29, 2023
1 parent d4a6229 commit a88fd5e
Showing 1 changed file with 163 additions and 179 deletions.
Loading

0 comments on commit a88fd5e

Please sign in to comment.