Skip to content

Commit

Permalink
Thread safe lock-free iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoV committed Feb 6, 2024
1 parent 92abb01 commit 8d3080b
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 36 deletions.
2 changes: 2 additions & 0 deletions Include/internal/pycore_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ static inline PyDictUnicodeEntry* DK_UNICODE_ENTRIES(PyDictKeysObject *dk) {
#define DICT_VERSION_INCREMENT (1 << (DICT_MAX_WATCHERS + DICT_WATCHED_MUTATION_BITS))
#define DICT_WATCHER_MASK ((1 << DICT_MAX_WATCHERS) - 1)

#define DICT_VALUES_USED_SIZE(values) ((uint8_t *)values)[-2]

#ifdef Py_GIL_DISABLED
#define DICT_NEXT_VERSION(INTERP) \
(_Py_atomic_add_uint64(&(INTERP)->dict_state.global_version, DICT_VERSION_INCREMENT) + DICT_VERSION_INCREMENT)
Expand Down
Loading

0 comments on commit 8d3080b

Please sign in to comment.