Skip to main content

AllocationLock

Trait AllocationLock 

Source
pub trait AllocationLock:
    Debug
    + Send
    + Sync {
    // Required method
    fn acquire<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<AllocationGuard, AllocationLockBusy>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Flow 2.4’s “takes the host-wide allocation lock before creating each local runtime”, as a port.

§Why a lock is needed at all, given the allocator already exists

HostAllocator enforces D9 across the policies of one pass. It cannot enforce anything across two passes running at once, and f3 runs one demand-polling loop per target: without serialisation, two loops read the same headroom, each finds it sufficient, and the host ends up with the sum of two grants it only ever had room for one of. The lock is what makes the read-decide-create sequence atomic, and it is taken once per runtime rather than once per pass so that a slow package download in one policy does not hold the whole host still.

Required Methods§

Source

fn acquire<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<AllocationGuard, AllocationLockBusy>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Take the lock, waiting briefly for it.

§Errors

AllocationLockBusy when it could not be taken. A refused grant is always safe: the next pass re-reads the headroom and tries again.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§