diff options
| author | Mica White <botahamec@outlook.com> | 2026-03-14 21:33:50 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-03-14 21:33:50 -0400 |
| commit | 482b47f4ed786946acb324b60d9f7ae7dd8cc075 (patch) | |
| tree | 4216f042597679f2b76adbb61d3ba9596e96a060 /src/collection/retry.rs | |
| parent | d9095d8fce59714f75019ecf68911d9931a1af15 (diff) | |
Diffstat (limited to 'src/collection/retry.rs')
| -rwxr-xr-x | src/collection/retry.rs | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/collection/retry.rs b/src/collection/retry.rs index 4a5df6e..b9ac530 100755 --- a/src/collection/retry.rs +++ b/src/collection/retry.rs @@ -154,36 +154,39 @@ unsafe impl<L: Lockable> RawLock for RetryingLockCollection<L> { handle_unwind( || 'outer: loop { // safety: we have the thread key - locks[first_index.get()].raw_read(); - for (i, lock) in locks.iter().enumerate() { - if i == first_index.get() { - continue; - } - - // safety: we have the thread key - if lock.raw_try_read() { - locked.set(locked.get() + 1); - } else { - // safety: we already locked all of these - attempt_to_recover_reads_from_panic(&locks[0..i]); + unsafe { + locks[first_index.get()].raw_read(); - if first_index.get() >= i { - // safety: this is already locked and can't be unlocked - // by the previous loop - locks[first_index.get()].raw_unlock_read(); + for (i, lock) in locks.iter().enumerate() { + if i == first_index.get() { + continue; } - // these are no longer locked - locked.set(0); + // safety: we have the thread key + if lock.raw_try_read() { + locked.set(locked.get() + 1); + } else { + // safety: we already locked all of these + attempt_to_recover_reads_from_panic(&locks[0..i]); + + if first_index.get() >= i { + // safety: this is already locked and can't be unlocked + // by the previous loop + locks[first_index.get()].raw_unlock_read(); + } + + // these are no longer locked + locked.set(0); - // don't go into a spin loop, wait for this one to lock - first_index.set(i); - continue 'outer; + // don't go into a spin loop, wait for this one to lock + first_index.set(i); + continue 'outer; + } } - } - // safety: we locked all the data - break; + // safety: we locked all the data + break; + } }, || { utils::attempt_to_recover_reads_from_panic(&locks[0..locked.get()]); @@ -1019,7 +1022,7 @@ mod tests { } #[test] - #[allow(clippy::float_cmp)] + #[expect(clippy::float_cmp)] fn uses_correct_default() { let collection = RetryingLockCollection::<(RwLock<f64>, Mutex<Option<i32>>, Mutex<usize>)>::default(); |
