All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.io.ktor.client.utils.CIOJvm.kt Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
 */

package io.ktor.client.utils

import io.ktor.util.*
import io.ktor.utils.io.pool.*
import io.ktor.utils.io.pool.ByteBufferPool
import java.nio.*

/**
 * Singleton pool of [ByteBuffer] objects used for [HttpClient].
 */
public val HttpClientDefaultPool: ByteBufferPool = ByteBufferPool()

@InternalAPI
@Deprecated(
    level = DeprecationLevel.ERROR,
    message = "ByteBufferPool is moved to `io` module",
    replaceWith = ReplaceWith("ByteBufferPool", "io.ktor.utils.io.pool.ByteBufferPool")
)
public class ByteBufferPool : DefaultPool(DEFAULT_HTTP_POOL_SIZE) {
    override fun produceInstance(): ByteBuffer = ByteBuffer.allocate(DEFAULT_HTTP_BUFFER_SIZE)!!

    override fun clearInstance(instance: ByteBuffer): ByteBuffer = instance.apply {
        clear()
        order(ByteOrder.BIG_ENDIAN)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy