Adapt the cutover to the reviewed core-types API

This commit is contained in:
Dennis Kobert
2026-07-31 23:39:39 +02:00
parent 81a319430b
commit c30054579f
24 changed files with 170 additions and 145 deletions

View File

@@ -84,6 +84,18 @@ impl Arena {
})
}
/// An arena that refuses every allocation and resolves no handle, so a caller that
/// cannot fail can degrade instead of propagating exhaustion.
pub fn parked() -> Self {
LIVE_ARENAS.fetch_add(1, Ordering::Release);
Self {
generation: AtomicU64::new(PARKED_GENERATION),
offset: AtomicUsize::new(0),
buf: Box::new([]),
drops: Mutex::new(Vec::new()),
}
}
pub fn generation(&self) -> u64 {
self.generation.load(Ordering::Acquire)
}

View File

@@ -17,6 +17,13 @@ struct FrameSlot<T> {
value: UnsafeCell<MaybeUninit<T>>,
}
// SAFETY: the key CAS reserves a slot for one writer, and the Release store of its
// state publishes the value to every Acquire load in `lookup`, so concurrent access
// is ordered. Sharing the table hands out `&T` and drops `T` on whichever thread
// drops the table, which is what the `Send + Sync` bounds cover.
unsafe impl<T: Send + Sync, const CAP: usize> Sync for FrameTable<T, CAP> {}
unsafe impl<T: Send, const CAP: usize> Send for FrameTable<T, CAP> {}
pub enum Lookup<'t, T> {
Hit(Finality, &'t T),
Vacant(VacantSlot<'t, T>),

View File

@@ -333,7 +333,7 @@ mod tests {
type ErasedSplitEdge = dyn for<'c> Node<ContextImpl<'c>, Output = SplitBorrow<'c>> + Send + Sync;
let arena = Arena::new(4096);
let arena = Arena::new(4096).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -391,7 +391,7 @@ mod tests {
}
}
let arena = Arena::new(1024);
let arena = Arena::new(1024).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -443,7 +443,7 @@ mod tests {
}
}
let arena = Arena::new(1024);
let arena = Arena::new(1024).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -493,7 +493,7 @@ mod tests {
#[test]
fn duplicated_edges_share_one_instance_and_outlive_each_other() {
let arena = Arena::new(1024);
let arena = Arena::new(1024).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);

View File

@@ -281,7 +281,7 @@ mod tests {
#[test]
fn async_source_spawns_once_and_lands_via_the_slot() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -301,7 +301,7 @@ mod tests {
#[test]
fn async_source_reports_the_placeholder_while_in_flight() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -316,7 +316,7 @@ mod tests {
#[test]
fn no_partial_maps_the_placeholder_frame_to_pending() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -331,7 +331,7 @@ mod tests {
#[test]
fn prologue_runs_sync_and_spawns_once() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -350,7 +350,7 @@ mod tests {
#[test]
fn prologue_interrupt_defers_the_spawn() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let ctx = ContextImpl::root(&scope);
@@ -369,7 +369,7 @@ mod tests {
#[test]
fn async_kernels_read_captured_varargs() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let root = ContextImpl::root(&scope);
@@ -390,7 +390,7 @@ mod tests {
#[test]
fn async_kernels_read_the_captured_context_snapshot() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let generations = [];
let scope = scope_fixture(&generations, &arena);
let root = ContextImpl::root(&scope);
@@ -484,7 +484,7 @@ mod tests {
#[test]
fn a_source_slot_lands_through_the_runtime_while_downstream_keys_invalidate() {
let arena = Arena::new(64);
let arena = Arena::new(64).unwrap();
let runtime = Arc::new(GraphRuntime::new(CollectSpawner::default()));
runtime.retain_sources(&[11]);
let graph = EpilogueDoubleNode::new(SourceNode(21.0f64), SourceNode(RuntimeHandle(runtime.clone())), SourceNode(11u64));