mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-112075: Make PyDictKeysObject thread-safe (#114741)
Adds locking for shared PyDictKeysObject's for dictionaries
This commit is contained in:
parent
145bc2d638
commit
176df09adb
6 changed files with 257 additions and 93 deletions
|
|
@ -136,6 +136,11 @@ struct _dictkeysobject {
|
|||
/* Kind of keys */
|
||||
uint8_t dk_kind;
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
/* Lock used to protect shared keys */
|
||||
PyMutex dk_mutex;
|
||||
#endif
|
||||
|
||||
/* Version number -- Reset to 0 by any modification to keys */
|
||||
uint32_t dk_version;
|
||||
|
||||
|
|
@ -145,6 +150,7 @@ struct _dictkeysobject {
|
|||
/* Number of used entries in dk_entries. */
|
||||
Py_ssize_t dk_nentries;
|
||||
|
||||
|
||||
/* Actual hash table of dk_size entries. It holds indices in dk_entries,
|
||||
or DKIX_EMPTY(-1) or DKIX_DUMMY(-2).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue