LocalSoftDeadline

LocalSoftDeadline stops the pipeline after a given duration has elapsed since the last successful evolution transition. The clock resets on every Status.Success transition, so the deadline window starts fresh after each successful step. On a Complete or error transition the clock also resets, but the deadline is checked at the very next apply call.

If the elapsed time reaches duration when apply is called, the current yield's status is upgraded to Status.Complete. If duration ≤ 0, the factory returns DeadEnd directly.

This contrasts with GlobalSoftDeadline, whose deadline is fixed at construction and never resets.

The factory has two overloads:

import h8io.stages.*
import h8io.stages.base.*
import h8io.stages.operators.*
var t = 0L
// t: Long = 0L
val stage = LocalSoftDeadline[String, String, Nothing](() => t, () => t, 3L, PassThrough)
// stage: LocalSoftDeadline[String, String, Nothing] = LocalSoftDeadline(
//   tsSupplier = <function0>,
//   now = <function0>,
//   duration = 3L,
//   alterand = <function1>
// )

val r1 = stage("first")        // ts=0, now=0, elapsed=0 < 3 → Success
// r1: Yield[String, String, Nothing] = Some(
//   out = "first",
//   status = Success,
//   evolution = Evolution(
//     tsSupplier = h8io.stages.operators.LocalSoftDeadline$$Lambda$14368/0x00007f2c92643968@5e0195c8,
//     now = <function0>,
//     duration = 3L,
//     evolution = <function1>
//   )
// )
t = 4L
val r2 = r1.evolve()("second") // ts=0, now=4, elapsed=4 ≥ 3 → Complete
// r2: Yield[String, String, Nothing] = Some(
//   out = "second",
//   status = Complete(),
//   evolution = Evolution(
//     tsSupplier = <function0>,
//     now = <function0>,
//     duration = 3L,
//     evolution = <function1>
//   )
// )