void _PySeqLock_LockWrite(_PySeqLock *seqlock)
{
- // lock the entry by setting by moving to an odd sequence number
+ // lock by moving to an odd sequence number
uint32_t prev = _Py_atomic_load_uint32_relaxed(&seqlock->sequence);
while (1) {
if (SEQLOCK_IS_UPDATING(prev)) {
void _PySeqLock_AbandonWrite(_PySeqLock *seqlock)
{
- uint32_t new_seq = seqlock->sequence - 1;
+ uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) - 1;
assert(!SEQLOCK_IS_UPDATING(new_seq));
_Py_atomic_store_uint32(&seqlock->sequence, new_seq);
}
void _PySeqLock_UnlockWrite(_PySeqLock *seqlock)
{
- uint32_t new_seq = seqlock->sequence + 1;
+ uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) + 1;
assert(!SEQLOCK_IS_UPDATING(new_seq));
_Py_atomic_store_uint32(&seqlock->sequence, new_seq);
}