KetraTerm
API · DevelopmentAll versions

TerminalRenderPublisher

class TerminalRenderPublisher(columns: Int, rows: Int)

Triple-buffered render cache publisher.

One buffer is writer-owned (back). One buffer is UI-readable (front). One buffer is spare (recycled after front is replaced).

Writer and UI never touch the same buffer simultaneously when UI consumers access the front buffer through readCurrent. Retired buffers release their image references after their last reader leaves; primitive row storage remains reusable for later publications.

The public inline reader avoids a callback allocation; non-inline operations own lease acquisition and release. Only cache-reference acquisition/release is part of the reader ABI; buffer layout, indices, locks and counters remain private.

Parameters

columns

initial cache width in cells.

rows

initial cache height in rows.

Constructors

Link copied to clipboard
constructor(columns: Int, rows: Int)

Functions

Link copied to clipboard

Pins the current cache, or returns null before the first publication.

Link copied to clipboard
inline fun <T> readCurrent(block: (TerminalRenderCache) -> T): T?

Reads the latest published front buffer while preventing it from being recycled as a writer-owned back buffer.

Link copied to clipboard

Releases one successful acquireFrontLease using the identical cache reference.

Link copied to clipboard

Called from render worker thread only. Reads from reader, updates back buffer, publishes as new front.

fun updateAndPublish(reader: TerminalRenderFrameReader, scrollbackOffset: Int)
fun updateAndPublish(reader: TerminalRenderFrameReader, scrollbackOffset: Int, viewportRows: Int)

Called from render worker thread only.