/// Try to cache an Arena.
/// If the Cache is full and the new Arena will be cached the old Arena with the least capacity will be returned.
Try to cache an Arena.
If the Cache is full and the new Arena will be cached the old Arena with the least capacity will be returned.
Try to cache an Arena . If the Cache is full and the new Arena will be cached the old Arena with the least capacity will be returned .
fn put<T>(&mut self, next: *mut T, size: u16, align: u16) -> CacheStatus<T> {
        let header = HeaderUnTyped::from(next as _);
        // log::trace!(
        //     "CachedArenas::put(header: {:?}, next: {:?}, new_allocation: {:?})",
        //     header,
        //     next,
        //     new_allocation
        // );
        // log::trace!("CachedArenas::put {:?}", self);
        debug_assert!(self
            .0
            .iter()
            .find(|ca| HeaderUnTyped::from(ca.next()) == header)
            .is_none());
        let (cached_arena, cap) = self
            .0
            .iter_mut()
            .map(|a| {
                let cap = capacity(a.next() as _, size, align);
                (a, cap)
            })
            .min_by(|(_, ac), (_, bc)| ac.cmp(bc))
            .unwrap();
        if cap < capacity(next as _, size, align) {
            let r = if cached_arena.is_null() {
                CacheStatus::Stored
            } else {
                CacheStatus::Cached(cached_arena.next() as _)
            };
            *cached_arena = CachedArena::new(next as _);
            log::trace!("WORKER: CachedArenas::put modified {:?}", self);
            r
        } else {
            CacheStatus::Err
        }
    }
fn put < T > ( & mut self , next : * mut T , size : u16 , align : u16 ) -> CacheStatus < T > { let header = HeaderUnTyped :: from ( next as _ ) ; // log::trace!( //     "CachedArenas::put(header: {:?}, next: {:?}, new_allocation: {:?})", //     header, //     next, //     new_allocation // ); // log::trace!("CachedArenas::put {:?}", self); debug_assert ! ( self 0 iter ( ) find ( ca HeaderUnTyped from ( ca next ( ) ) header ) is_none ( ) ) ; let ( cached_arena , cap ) = self . 0 . iter_mut ( ) . map ( | a | { let cap = capacity ( a . next ( ) as _ , size , align ) ; ( a , cap ) } ) . min_by ( | ( _ , ac ) , ( _ , bc ) | ac . cmp ( bc ) ) . unwrap ( ) ; if cap < capacity ( next as _ , size , align ) { let r = if cached_arena . is_null ( ) { CacheStatus :: Stored } else { CacheStatus :: Cached ( cached_arena . next ( ) as _ ) } ; * cached_arena = CachedArena :: new ( next as _ ) ; log :: trace ! ( " " self ) ; r } else { CacheStatus :: Err } }
Try to cache an Arena.
Try to cache an Arena .
&mut self
next
*mut T
size
u16
align
u16