This works but without the buffer functions I'm ba...
# squarelibraries
p
This works but without the buffer functions I'm back to the stone age:
Copy code
@Test
fun pipe() {
    val pipe = Pipe(Long.MAX_VALUE)

    thread {
        val sink = pipe.sink
        repeat(10) { i ->
            Thread.sleep(1000)
            val b = Buffer().apply {
                println("write $i")
                writeInt(i)
            }
            sink.write(b, b.size)
        }
    }

    while (true) {
        val sink = Buffer()
        pipe.source.read(sink, 4)
        val int = sink.readInt()
        println("read $int")
    }
}