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

appleMain.com.adeo.kviewmodel.odyssey.ConcurrentHashMap.apple.kt Maven / Gradle / Ivy

The newest version!
package com.adeo.kviewmodel.odyssey

import kotlinx.atomicfu.locks.SynchronizedObject
import kotlinx.atomicfu.locks.synchronized

public actual class ConcurrentHashMap(
    private val delegate: HashMap = HashMap()
) : MutableMap by delegate {

    public actual constructor() : this(HashMap())

    private val sync = SynchronizedObject()

    override val size: Int
        get() = synchronized(sync) { delegate.size }

    override fun get(key: K): V? = synchronized(sync) { delegate.get(key) }

    override fun put(key: K, value: V): V? = synchronized(sync) { delegate.put(key, value) }

    override fun remove(key: K): V? = synchronized(sync) { delegate.remove(key) }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy