sdeleuze
01/02/2023, 5:29 PMmbonnin
01/02/2023, 5:35 PMWe're extracting the IO functionality into a separate library. This is a long-standing task that we've been working on gradually, and aim to finalize in 2023
I'd personally love Kotlin to endorse Okio as the default I/O library. It has kotlinx.serialization APIs already and some proven multiplatform usage.
Using it everywhere would allow those Okio buffers to be shared without copy.sdeleuze
01/02/2023, 5:36 PMOleg Yukhnevich
01/02/2023, 5:44 PMsdeleuze
01/02/2023, 5:49 PMOleg Yukhnevich
01/02/2023, 5:56 PMJeff Lockhart
01/02/2023, 9:49 PMJeff Lockhart
01/02/2023, 9:56 PMBufferedSource
-> NSInputStream
and NSInputStream
-> Source
Apple Foundation 0 copy API support is implemented in this PR.Oleg Yukhnevich
01/02/2023, 10:45 PMJeff Lockhart
01/03/2023, 12:41 AMokio is great library for working with buffers, but it’s not general IO library.
Thanks for the detailed explanation. That makes sense. As for the
NSInputStream
API implementation, I was concerned extra memory copies would be necessary as well. But I found since it's possible to read and write directly to and from the ByteArray
buffer as native CPointer<uint8_tVar>
, it's possible to wrap the Okio API to implement the Apple Foundation API and vice versa, with only the single stream to buffer memory copy the APIs call for.
It may be possible to accomplish something similar with JS and WASM APIs as well.