add SoftConcurrentMap

This commit is contained in:
Looly
2023-06-24 19:41:24 +08:00
parent ece736d5d4
commit ac3fdeafca

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2023 looly(loolly@aliyun.com)
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.dromara.hutool.core.map;
import org.dromara.hutool.core.util.ReferenceUtil;
import java.lang.ref.Reference;
import java.util.concurrent.ConcurrentMap;
/**
* 线程安全的SoftMap实现<br>
*
* @param <K> 键类型
* @param <V> 值类型
* @author looly
* @since 6.0.0
*/
public class SoftConcurrentMap<K, V> extends ReferenceConcurrentMap<K, V> {
private static final long serialVersionUID = 1L;
/**
* 构造
*/
public SoftConcurrentMap() {
this(new SafeConcurrentHashMap<>());
}
/**
* 构造
*
* @param raw {@link ConcurrentMap}实现
*/
public SoftConcurrentMap(final ConcurrentMap<Reference<K>, V> raw) {
super(raw, ReferenceUtil.ReferenceType.SOFT);
}
}