dope-core 0.77.0

Owned native I/O and completion driver for dope
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use o3::buffer::resident;

use crate::driver::storage::{Exhausted, resident::Alloc};

pub(super) fn claim<'d>(alloc: Alloc<'d>) -> Result<(usize, &'d mut resident::Domain), Exhausted> {
    let index = alloc.arena.next.get();
    let Some(slot) = alloc.arena.slots.get(index) else {
        return Err(Exhausted::Domains {
            capacity: alloc.arena.slots.len(),
        });
    };
    alloc.arena.next.set(index + 1);
    // SAFETY: Arena resets the monotonic cursor only under its unique
    // generation borrow, and this branch advances it before returning, so
    // no other allocation in `'d` can select this slot.
    let domain = unsafe { &mut *slot.get() };
    Ok((index, domain))
}