AndreiBogdan
11/09/2023, 10:05 AMmbonnin
11/09/2023, 10:12 AMByteReadChannel
manually with something like what's done on the JVM:
GlobalScope.writer(context, autoFlush = true) {
val buffer = pool.borrow()
try {
while (true) {
buffer.clear()
val readCount = read(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining())
if (readCount < 0) break
if (readCount == 0) continue
buffer.position(buffer.position() + readCount)
buffer.flip()
channel.writeFully(buffer)
}
} catch (cause: Throwable) {
channel.close(cause)
} finally {
pool.recycle(buffer)
close()
}
}.channel
okio.Source
but maybe ask in #io?GlobalScope.writer()
solution did not work?
PS: when crossposting, it's better to link to the original message this way it centralises the discussion in a single placeAndreiBogdan
11/15/2023, 10:21 AMmbonnin
11/15/2023, 10:28 AMGlobalScope.writer{}
?AndreiBogdan
11/15/2023, 10:32 AM