Fix generation race condition with sync storage (#2638)

* Fix generation race condition with sync storage

* Document GenerationalPointer

* check generation before recycling generational box

* fix clippy

* make race_condition_regression test panic if it fails
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-23 10:30:57 -07:00
1 parent 672f4dfefc
commit c7c0f4481a
13 files changed
+766 -675

No files matched your search

+11
View File
@@ -2,6 +2,8 @@ use std::error::Error;
use std::fmt::Debug;
use std::fmt::Display;
use crate::GenerationalLocation;
#[derive(Debug, Clone, PartialEq)]
/// An error that can occur when trying to borrow a value.
pub enum BorrowError {
@@ -61,6 +63,15 @@ impl ValueDroppedError {
created_at,
}
}
/// Create a new `ValueDroppedError` for a [`GenerationalLocation`].
#[allow(unused)]
pub(crate) fn new_for_location(location: GenerationalLocation) -> Self {
Self {
#[cfg(any(debug_assertions, feature = "debug_borrows"))]
created_at: location.created_at,
}
}
}
impl Display for ValueDroppedError {