Channel

interface Channel<T : Any>

Base type abstracting a channel of communication of T-typed elements between a it.unibo.tuprolog.solve.Solver and the outside world, without committing to a specific transport.

This is what lets Prolog built-ins like write/1, read/1, or warning reporting talk to the outside world uniformly whether the solver runs on the JVM (wrapping a java.io.PrintStream/Reader/Writer) or on JS (wrapping console.log), since a built-in only ever depends on this abstraction, never on a concrete transport. See InputChannel and OutputChannel for the two directions of communication, and it.unibo.tuprolog.solve.channel.ChannelStore for how several named channels are held together by a solver.

Every element transiting the channel (via InputChannel.read/OutputChannel.write) is broadcast to every registered Listener.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val isClosed: Boolean

Whether this channel has been closed.

Link copied to clipboard
abstract val streamTerm: Struct

The Prolog $stream(Direction, Id)-like Struct term identifying this channel, e.g. for current_output/1.

Functions

Link copied to clipboard
abstract fun addListener(listener: Listener<T?>)

Registers listener to be invoked with every element subsequently transiting this channel.

Link copied to clipboard
abstract fun clearListeners()

Unregisters every currently-registered Listener.

Link copied to clipboard
abstract fun close()

Closes this channel; further reads/writes on it are expected to fail.

Link copied to clipboard
abstract fun removeListener(listener: Listener<T?>)

Unregisters listener, previously added via addListener.