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

jvmMain.io.ktor.util.collections.ConcurrentMapJvm.kt Maven / Gradle / Ivy

/*
 * 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.util.collections

import io.ktor.util.*
import java.util.concurrent.*

@InternalAPI
actual class ConcurrentMap : MutableMap by ConcurrentHashMap() {
    actual fun getOrDefault(key: Key, block: () -> Value): Value {
        get(key)?.let { return it }

        val result = block()
        return putIfAbsent(key, result) ?: result
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy