liminal-server 0.24.1

Standalone server for the liminal messaging bus
Documentation
use super::{
    ConnectionTransport, DrainOutcome, Interest, NativeContext, NativeOutcome,
    TransportConnectionProcess, has_held_participant_head,
};

impl<T: ConnectionTransport> TransportConnectionProcess<T> {
    pub(super) fn finish_slice_readiness(
        &mut self,
        pid: u64,
        ctx: &mut NativeContext<'_>,
        drain: DrainOutcome,
    ) -> NativeOutcome {
        if let Err(error) = self.sync_deadline_timers(pid, ctx) {
            return self.fail_slice(pid, &error);
        }
        // A successful budget-limited write proves immediately actionable work
        // remains. Do not arm a permanently-writable socket in this state.
        if drain == DrainOutcome::Progress {
            return NativeOutcome::Continue;
        }
        if drain == DrainOutcome::Drained && has_held_participant_head(&self.state) {
            return NativeOutcome::Continue;
        }
        let interest = if drain == DrainOutcome::WouldBlockWithResidue {
            Interest::both()
        } else {
            Interest::READABLE
        };
        if let Some(outcome) = self.force_close_if_pending(pid) {
            return outcome;
        }
        if let Err(error) = self.arm_readiness(pid, ctx, interest) {
            return self.fail_slice(pid, &error);
        }
        #[cfg(test)]
        let barrier_staged = self.runtime.run_pre_wait_barrier();
        match self.final_probe(pid, ctx) {
            Ok(true) => {
                #[cfg(test)]
                if barrier_staged {
                    self.runtime.record_pre_wait_probe_hit();
                }
                NativeOutcome::Continue
            }
            Ok(false) => {
                #[cfg(test)]
                self.runtime.record_park(pid);
                // FIX A-ii: parked with every accepted publish flushed to the
                // socket (final_probe found no pending inbox/held delivery and no
                // READY edge). Tell the shutdown flush barrier this connection has
                // quiesced.
                self.runtime.mark_parked(pid);
                NativeOutcome::Wait
            }
            Err(error) => self.fail_slice(pid, &error),
        }
    }
}