toSequence

expect fun <T> ReceiveChannel<T>.toSequence(coroutineScope: CoroutineScope = backgroundScope): Sequence<T>

Converts this ReceiveChannel into a (blocking) Sequence, draining the channel from a coroutine launched on coroutineScope. This is what lets ConcurrentSolver implement the synchronous it.unibo.tuprolog.solve.Solver.solve contract in terms of the channel-based ConcurrentSolver.solveConcurrently: elements produced by concurrently running branches of the search tree are funnelled through a queue and replayed, one at a time, to whichever thread iterates the returned Sequence.

On the JVM, iteration blocks the consuming thread until either the next element becomes available or the channel is closed. On Kotlin/JS this is currently unimplemented (TODO, throws NotImplementedError).

Throws

on the current Kotlin/JS target.

actual fun <T> ReceiveChannel<T>.toSequence(coroutineScope: CoroutineScope): Sequence<T>

Converts this ReceiveChannel into a (blocking) Sequence, draining the channel from a coroutine launched on coroutineScope. This is what lets ConcurrentSolver implement the synchronous it.unibo.tuprolog.solve.Solver.solve contract in terms of the channel-based ConcurrentSolver.solveConcurrently: elements produced by concurrently running branches of the search tree are funnelled through a queue and replayed, one at a time, to whichever thread iterates the returned Sequence.

On the JVM, iteration blocks the consuming thread until either the next element becomes available or the channel is closed. On Kotlin/JS this is currently unimplemented (TODO, throws NotImplementedError).

Throws

on the current Kotlin/JS target.

actual fun <T> ReceiveChannel<T>.toSequence(coroutineScope: CoroutineScope): Sequence<T>

Converts this ReceiveChannel into a (blocking) Sequence, draining the channel from a coroutine launched on coroutineScope. This is what lets ConcurrentSolver implement the synchronous it.unibo.tuprolog.solve.Solver.solve contract in terms of the channel-based ConcurrentSolver.solveConcurrently: elements produced by concurrently running branches of the search tree are funnelled through a queue and replayed, one at a time, to whichever thread iterates the returned Sequence.

On the JVM, iteration blocks the consuming thread until either the next element becomes available or the channel is closed. On Kotlin/JS this is currently unimplemented (TODO, throws NotImplementedError).

Throws

on the current Kotlin/JS target.