Countdown

h8io.stages.std.Countdown
See theCountdown companion object
final case class Countdown[T](i: Long, n: Long) extends Endo[T, Nothing]

An endomorphic stage that passes its input through for exactly n invocations and then signals pipeline completion.

On each of the first n − 1 calls the stage yields h8io.stages.Status.Success and decrements its counter. On the n-th call it yields h8io.stages.Status.Complete and resets to n. After any h8io.stages.Status.Complete the stage also resets to n, ready for reuse — whether it was applied in that run or skipped.

Countdown is fully immutable: each state transition creates a new instance rather than mutating the current one.

Preconditions (checked at construction via require, which throws an IllegalArgumentException):

  • n > 0
  • 1 ≤ i ≤ n

Type parameters

T

the value type passed through unchanged

Value parameters

i

the remaining number of successful yields before completion (1 ≤ i ≤ n)

n

the total period length (must be positive)

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Fruitful[T, T, Nothing]
trait Stage[T, T, Nothing]
trait T => Yield[T, T, Nothing]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def apply(in: T): Some[T, T, Nothing]

Processes in and returns the Yield carrying the optional output, the status and the continuation.

Processes in and returns the Yield carrying the optional output, the status and the continuation.

A stage that throws from here must have released its own resources first — see the ''Lifecycle'' section above.

Attributes

Definition Classes
Fruitful -> Stage -> Function1
override def skip(): Endo[T, Nothing]

Keeps the counter where it is on h8io.stages.Status.Success, and resets it on any other status.

Keeps the counter where it is on h8io.stages.Status.Success, and resets it on any other status.

Attributes

Definition Classes

Inherited methods

def andThen[A](g: Yield[T, T, Nothing] => A): T => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def compose[A](g: A => T): A => Yield[T, T, Nothing]

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Function1 -> Any
Inherited from:
Function1
final def ~>[_O, _E >: Nothing](that: Stage[T, _O, _E]): Stage[T, _O, _E]

Composes this stage with that, feeding this stage's output into it. See the ''Composition'' section above for what happens when there is no output to feed.

Composes this stage with that, feeding this stage's output into it. See the ''Composition'' section above for what happens when there is no output to feed.

Attributes

Inherited from:
Stage