[Review] Move WeakRef to mirai-core-utils

This commit is contained in:
Him188 2021-01-06 15:13:15 +08:00
parent 3c0bc21816
commit 382d3d08d4
2 changed files with 2 additions and 22 deletions

View File

@ -1,14 +0,0 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package net.mamoe.mirai.utils
import java.lang.ref.WeakReference
public actual typealias WeakRef<T> = WeakReference<T>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -11,11 +11,8 @@
package net.mamoe.mirai.utils
import kotlin.jvm.JvmSynthetic
import kotlin.reflect.KProperty
// TODO: 2020/2/10 添加中文 doc
/**
* WeakRef that `getValue` for delegation throws an [IllegalStateException] if the referent is released by GC. Therefore it returns notnull value only
*/
@ -46,10 +43,7 @@ public inline operator fun <T> UnsafeWeakRef<T>.getValue(thisRef: Any?, property
* @see weakRef provides a WeakRef
* @see unsafeWeakRef provides a UnsafeWeakRef
*/
public expect class WeakRef<T>(referent: T) {
public fun get(): T?
public fun clear()
}
public typealias WeakRef<T> = java.lang.ref.WeakReference<T>
/**
* Indicates that the property is delegated by a [WeakRef]