jvmMain.kotlinx.io.nio.Output.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-io-jvm Show documentation
Show all versions of kotlinx-io-jvm Show documentation
IO support libraries for Kotlin
package kotlinx.io.nio
import kotlinx.io.core.*
import kotlinx.io.pool.*
import java.nio.channels.*
private class ChannelAsOutput(pool: ObjectPool,
val channel: WritableByteChannel
) : AbstractOutput(pool) {
override fun flush(buffer: IoBuffer) {
buffer.readDirect { bb ->
while (bb.hasRemaining()) {
channel.write(bb)
}
}
}
override fun closeDestination() {
channel.close()
}
}
fun WritableByteChannel.asOutput(pool: ObjectPool = IoBuffer.Pool): Output
= ChannelAsOutput(pool, this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy