pub(crate) unsafe fn step(&self, free: &mut FreeList) -> bool {
        log::info!("{:?}", self);
        let mut done = false;
        let state = &mut *self.state.get();
        let arenas: &mut Arenas = &mut *self.arenas.get();
        let pending = &mut *self.pending.get();
        let buses = &mut *self.buses.get();

        pending.epoch += 1;

        let mut grey: SmallVec<[(*const u8, u8); 16]> = SmallVec::new();

        buses
            .iter_mut()
            .for_each(|(thread_id, (bus, _count, worker_known_invariant))| {
                let msgs = {
                    let mut bus = &mut bus.lock().expect("Could not unlock bus").1;
                    let msgs = bus::reduce(&mut bus);

                    if *worker_known_invariant != self.invariant_id.get() {
                        *worker_known_invariant = self.invariant_id.get();

                        let inv = Msg::Invariant(
                            state
                                .as_mut()
                                .map(|cycle| {
                                    cycle.latest_grey = pending.epoch;
                                    cycle.handler.invariant
                                })
                                .unwrap_or_else(|| Invariant::none(self.invariant_id.get())),
                        );

                        // Send invariant replacing invariant currently on bus if it exists.
                        if let Some(slot) = bus.iter_mut().find(|msg| msg.is_invariant()) {
                            *slot = inv
                        } else {
                            bus.push(inv)
                        };

                        log::trace!("GC: sent thread {:?}, {:?}", thread_id, inv);
                    };

                    msgs
                };

                grey.extend(
                    msgs.iter().filter_map(|msg| {
                        self.book_keeping(*msg, *thread_id, state, pending, arenas)
                    }),
                );

                log::trace!("GC: Messages handled");

                log::trace!(
                    "GC: {:?}, worker_known_invariant: {}, self.invariant_id: {}",
                    thread_id,
                    worker_known_invariant,
                    self.invariant_id.get()
                );

                // if *count < 2 {
                //     *count += 1;
                //     let (next, top) = arenas.partial.remove_arena(&self.type_info, free);
                //     let header = HeaderUnTyped::from(next);

                //     arenas.worker.insert(header, (next, top));
                //     log::trace!("GC sent header: {:?}, next: {:?}", header, next);
                //     let mut bus = bus.lock().expect("Could not unlock bus");
                //     bus.push(Msg::Next(next as _))
                // };
            });

        log::trace!("grey: {:?}", grey);

        debug_assert!(if !grey.is_empty() {
            state.is_some()
        } else {
            true
        });

        // trace grey, updating refs
        if let Some(cycle) = state {
            let relations = &mut *self.relations.get();

            grey.iter().for_each(|(next, bits)| {
                // Grey worker marked types.
                relations
                    .direct_children
                    .iter()
                    .for_each(|(cts, (_, offsets))| {
                        let epoch = (&mut *cts.pending.get()).epoch;
                        let state = &mut *cts.state.get();

                        state.iter_mut().for_each(|cycle| {
                            if *offsets & *bits == 0b0 {
                                cycle.latest_grey = epoch;
                            };
                        });
                    });

                cycle
                    .handler
                    .root(*next as *mut u8, self.type_info.align, self.type_info.size)
            });

            log::trace!("cycle.evac_roots");

            // FIXME
            // cycle.evac_roots(&self.type_info, arenas, free);

            log::trace!("while cycle.handler.root_grey_children");
            while cycle.handler.root_grey_children() {}

            log::trace!("cycle.safe_to_free");
            if cycle.safe_to_free(pending, relations) {
                log::trace!("safe_to_free: {}", self.type_info.type_name);

                cycle
                    .condemned
                    .full
                    .drain()
                    .for_each(|(header, top)| self.drop_arena(header as *mut u8, top, free));

                cycle
                    .condemned
                    .partial
                    .0
                    .drain()
                    .into_iter()
                    .for_each(|(_, (next, top))| self.drop_arena(next as _, top, free));

                if self.type_info.needs_drop {
                    cycle.condemned.worker.drain().for_each(|(_, range)| {
                        self.drop_objects(HeaderUnTyped::from(range.0) as *mut _, range)
                    });
                };

                let children_complete = relations
                    .direct_children
                    .iter()
                    .filter(|(cts, _)| *cts != self)
                    .all(|(cts, _)| {
                        { &*cts.state.get() }
                            .as_ref()
                            .map(|cycle| cycle.condemned.is_empty())
                            .unwrap_or(true)
                    });

                if children_complete {
                    log::trace!("Children complete Collection cleared!");
                    // This will trigger the Invariant::none to be sent to the workers.
                    log::trace!("pending.known_grey: {}", pending.known_grey);
                    debug_assert_eq!(pending.known_grey, 0);
                    log::trace!(
                        "pending.arenas: len: {}, {:?}",
                        pending.arenas.len(),
                        pending.arenas
                    );

                    self.bump_invariant_id(pending);

                    log::trace!("clearing state");
                    cycle.handler.drop();
                    *state = None;
                    log::trace!("state cleared");
                    done = true;
                    self.major_cycle.fetch_add(1, Ordering::Release);
                };
            };
        };

        log::trace!("step::done: {:?}", done);
        done
    }
/// For safe usage See `TypeState` docs.
/// Returns true when collection is complete.
For safe usage See `TypeState` docs.
Returns true when collection is complete.
For safe usage See ` TypeState ` docs . Returns true when collection is complete .
pub(crate) unsafe fn step(&self, free: &mut FreeList) -> bool {
        log::info!("{:?}", self);
        let mut done = false;
        let state = &mut *self.state.get();
        let arenas: &mut Arenas = &mut *self.arenas.get();
        let pending = &mut *self.pending.get();
        let buses = &mut *self.buses.get();
        pending.epoch += 1;
        let mut grey: SmallVec<[(*const u8, u8); 16]> = SmallVec::new();
        buses
            .iter_mut()
            .for_each(|(thread_id, (bus, _count, worker_known_invariant))| {
                let msgs = {
                    let mut bus = &mut bus.lock().expect("Could not unlock bus").1;
                    let msgs = bus::reduce(&mut bus);
                    if *worker_known_invariant != self.invariant_id.get() {
                        *worker_known_invariant = self.invariant_id.get();
                        let inv = Msg::Invariant(
                            state
                                .as_mut()
                                .map(|cycle| {
                                    cycle.latest_grey = pending.epoch;
                                    cycle.handler.invariant
                                })
                                .unwrap_or_else(|| Invariant::none(self.invariant_id.get())),
                        );
                        // Send invariant replacing invariant currently on bus if it exists.
                        if let Some(slot) = bus.iter_mut().find(|msg| msg.is_invariant()) {
                            *slot = inv
                        } else {
                            bus.push(inv)
                        };
                        log::trace!("GC: sent thread {:?}, {:?}", thread_id, inv);
                    };
                    msgs
                };
                grey.extend(
                    msgs.iter().filter_map(|msg| {
                        self.book_keeping(*msg, *thread_id, state, pending, arenas)
                    }),
                );
                log::trace!("GC: Messages handled");
                log::trace!(
                    "GC: {:?}, worker_known_invariant: {}, self.invariant_id: {}",
                    thread_id,
                    worker_known_invariant,
                    self.invariant_id.get()
                );
                // if *count < 2 {
                //     *count += 1;
                //     let (next, top) = arenas.partial.remove_arena(&self.type_info, free);
                //     let header = HeaderUnTyped::from(next);
                //     arenas.worker.insert(header, (next, top));
                //     log::trace!("GC sent header: {:?}, next: {:?}", header, next);
                //     let mut bus = bus.lock().expect("Could not unlock bus");
                //     bus.push(Msg::Next(next as _))
                // };
            });
        log::trace!("grey: {:?}", grey);
        debug_assert!(if !grey.is_empty() {
            state.is_some()
        } else {
            true
        });
        // trace grey, updating refs
        if let Some(cycle) = state {
            let relations = &mut *self.relations.get();
            grey.iter().for_each(|(next, bits)| {
                // Grey worker marked types.
                relations
                    .direct_children
                    .iter()
                    .for_each(|(cts, (_, offsets))| {
                        let epoch = (&mut *cts.pending.get()).epoch;
                        let state = &mut *cts.state.get();
                        state.iter_mut().for_each(|cycle| {
                            if *offsets & *bits == 0b0 {
                                cycle.latest_grey = epoch;
                            };
                        });
                    });
                cycle
                    .handler
                    .root(*next as *mut u8, self.type_info.align, self.type_info.size)
            });
            log::trace!("cycle.evac_roots");
            // FIXME
            // cycle.evac_roots(&self.type_info, arenas, free);
            log::trace!("while cycle.handler.root_grey_children");
            while cycle.handler.root_grey_children() {}
            log::trace!("cycle.safe_to_free");
            if cycle.safe_to_free(pending, relations) {
                log::trace!("safe_to_free: {}", self.type_info.type_name);
                cycle
                    .condemned
                    .full
                    .drain()
                    .for_each(|(header, top)| self.drop_arena(header as *mut u8, top, free));
                cycle
                    .condemned
                    .partial
                    .0
                    .drain()
                    .into_iter()
                    .for_each(|(_, (next, top))| self.drop_arena(next as _, top, free));
                if self.type_info.needs_drop {
                    cycle.condemned.worker.drain().for_each(|(_, range)| {
                        self.drop_objects(HeaderUnTyped::from(range.0) as *mut _, range)
                    });
                };
                let children_complete = relations
                    .direct_children
                    .iter()
                    .filter(|(cts, _)| *cts != self)
                    .all(|(cts, _)| {
                        { &*cts.state.get() }
                            .as_ref()
                            .map(|cycle| cycle.condemned.is_empty())
                            .unwrap_or(true)
                    });
                if children_complete {
                    log::trace!("Children complete Collection cleared!");
                    // This will trigger the Invariant::none to be sent to the workers.
                    log::trace!("pending.known_grey: {}", pending.known_grey);
                    debug_assert_eq!(pending.known_grey, 0);
                    log::trace!(
                        "pending.arenas: len: {}, {:?}",
                        pending.arenas.len(),
                        pending.arenas
                    );
                    self.bump_invariant_id(pending);
                    log::trace!("clearing state");
                    cycle.handler.drop();
                    *state = None;
                    log::trace!("state cleared");
                    done = true;
                    self.major_cycle.fetch_add(1, Ordering::Release);
                };
            };
        };
        log::trace!("step::done: {:?}", done);
        done
    }
pub ( crate ) unsafe fn step ( & self , free : & mut FreeList ) -> bool { log :: info ! ( " " self ) ; let mut done = false ; let state = & mut * self . state . get ( ) ; let arenas : & mut Arenas = & mut * self . arenas . get ( ) ; let pending = & mut * self . pending . get ( ) ; let buses = & mut * self . buses . get ( ) ; pending . epoch += 1 ; let mut grey : SmallVec < [ ( * const u8 , u8 ) ; 16 ] > = SmallVec :: new ( ) ; buses . iter_mut ( ) . for_each ( | ( thread_id , ( bus , _count , worker_known_invariant ) ) | { let msgs = { let mut bus = & mut bus . lock ( ) . expect ( " " ) . 1 ; let msgs = bus :: reduce ( & mut bus ) ; if * worker_known_invariant != self . invariant_id . get ( ) { * worker_known_invariant = self . invariant_id . get ( ) ; let inv = Msg :: Invariant ( state . as_mut ( ) . map ( | cycle | { cycle . latest_grey = pending . epoch ; cycle . handler . invariant } ) . unwrap_or_else ( | | Invariant :: none ( self . invariant_id . get ( ) ) ) , ) ; // Send invariant replacing invariant currently on bus if it exists. if let Some ( slot ) = bus . iter_mut ( ) . find ( | msg | msg . is_invariant ( ) ) { * slot = inv } else { bus . push ( inv ) } ; log :: trace ! ( " " thread_id inv ) ; } ; msgs } ; grey . extend ( msgs . iter ( ) . filter_map ( | msg | { self . book_keeping ( * msg , * thread_id , state , pending , arenas ) } ) , ) ; log :: trace ! ( " " ) ; log :: trace ! ( " " thread_id worker_known_invariant self invariant_id get ( ) ) ; // if *count < 2 { //     *count += 1; //     let (next, top) = arenas.partial.remove_arena(&self.type_info, free); //     let header = HeaderUnTyped::from(next); //     arenas.worker.insert(header, (next, top)); //     log::trace!("GC sent header: {:?}, next: {:?}", header, next); //     let mut bus = bus.lock().expect("Could not unlock bus"); //     bus.push(Msg::Next(next as _)) // }; } ) ; log :: trace ! ( " " grey ) ; debug_assert ! ( if grey is_empty ( ) { state is_some ( ) } else { true } ) ; // trace grey, updating refs if let Some ( cycle ) = state { let relations = & mut * self . relations . get ( ) ; grey . iter ( ) . for_each ( | ( next , bits ) | { // Grey worker marked types. relations . direct_children . iter ( ) . for_each ( | ( cts , ( _ , offsets ) ) | { let epoch = ( & mut * cts . pending . get ( ) ) . epoch ; let state = & mut * cts . state . get ( ) ; state . iter_mut ( ) . for_each ( | cycle | { if * offsets & * bits == 0b0 { cycle . latest_grey = epoch ; } ; } ) ; } ) ; cycle . handler . root ( * next as * mut u8 , self . type_info . align , self . type_info . size ) } ) ; log :: trace ! ( " " ) ; // FIXME // cycle.evac_roots(&self.type_info, arenas, free); log :: trace ! ( " " ) ; while cycle . handler . root_grey_children ( ) { } log :: trace ! ( " " ) ; if cycle . safe_to_free ( pending , relations ) { log :: trace ! ( " " self type_info type_name ) ; cycle . condemned . full . drain ( ) . for_each ( | ( header , top ) | self . drop_arena ( header as * mut u8 , top , free ) ) ; cycle . condemned . partial . 0 . drain ( ) . into_iter ( ) . for_each ( | ( _ , ( next , top ) ) | self . drop_arena ( next as _ , top , free ) ) ; if self . type_info . needs_drop { cycle . condemned . worker . drain ( ) . for_each ( | ( _ , range ) | { self . drop_objects ( HeaderUnTyped :: from ( range . 0 ) as * mut _ , range ) } ) ; } ; let children_complete = relations . direct_children . iter ( ) . filter ( | ( cts , _ ) | * cts != self ) . all ( | ( cts , _ ) | { { & * cts . state . get ( ) } . as_ref ( ) . map ( | cycle | cycle . condemned . is_empty ( ) ) . unwrap_or ( true ) } ) ; if children_complete { log :: trace ! ( " " ) ; // This will trigger the Invariant::none to be sent to the workers. log :: trace ! ( " " pending known_grey ) ; debug_assert_eq ! ( pending known_grey 0 ) ; log :: trace ! ( " " pending arenas len ( ) pending arenas ) ; self . bump_invariant_id ( pending ) ; log :: trace ! ( " " ) ; cycle . handler . drop ( ) ; * state = None ; log :: trace ! ( " " ) ; done = true ; self . major_cycle . fetch_add ( 1 , Ordering :: Release ) ; } ; } ; } ; log :: trace ! ( " " done ) ; done }
For safe usage See `TypeState` docs.
For safe usage See ` TypeState ` docs .
&self
free
&mut FreeList
&self
free
&mut FreeList