Align docs with USE_CYCLIC_GC=0 (ed36f02c)
Co-authored-by: ilya-g <ilya.gorbunov@jetbrains.com>
This commit is contained in:
committed by
GitHub
parent
3c2b742ba9
commit
db9361f8a2
+4
-4
@@ -199,10 +199,10 @@ To achieve such functionality Kotlin/Native runtime provides two related classes
|
|||||||
`kotlin.native.concurrent.AtomicReference` and `kotlin.native.concurrent.FreezableAtomicReference`.
|
`kotlin.native.concurrent.AtomicReference` and `kotlin.native.concurrent.FreezableAtomicReference`.
|
||||||
Atomic reference holds reference to a frozen or immutable object, and its value could be updated by set
|
Atomic reference holds reference to a frozen or immutable object, and its value could be updated by set
|
||||||
or compare-and-swap operation. Thus, dedicated set of objects could be used to create mutable shared object graphs
|
or compare-and-swap operation. Thus, dedicated set of objects could be used to create mutable shared object graphs
|
||||||
(of immutable objects). Cycles in the shared memory could be created using atomic references, and to collect them
|
(of immutable objects). Cycles in the shared memory could be created using atomic references.
|
||||||
Kotlin/Native runtime has special concurrent cycle collector, concurrently analyzing cyclic data rooted in atomic references.
|
Kotlin/Native runtime doesn't support garbage collecting cyclic data when reference cycle goes through
|
||||||
When cycle of no longer used objects is detected, collector zeroes out reference stored in atomic reference and thus
|
`AtomicReference` or frozen `FreezableAtomicReference`. So to avoid memory leaks atomic references
|
||||||
allows cycle to be collected.
|
that are potentially parts of shared cyclic data should be zeroed out once no longer needed.
|
||||||
|
|
||||||
If atomic reference value is attempted to be set to non-frozen value runtime exception is thrown.
|
If atomic reference value is attempted to be set to non-frozen value runtime exception is thrown.
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ private fun debugString(value: Any?): String {
|
|||||||
/**
|
/**
|
||||||
* An atomic reference to a frozen Kotlin object. Can be used in concurrent scenarious
|
* An atomic reference to a frozen Kotlin object. Can be used in concurrent scenarious
|
||||||
* but frequently shall be of nullable type and be zeroed out once no longer needed.
|
* but frequently shall be of nullable type and be zeroed out once no longer needed.
|
||||||
* Asynchronous cycle collector takes care of cyclic references of that kind.
|
* Otherwise memory leak could happen if the atomic reference is a part of a reference cycle.
|
||||||
*/
|
*/
|
||||||
@Frozen
|
@Frozen
|
||||||
@LeakDetectorCandidate
|
@LeakDetectorCandidate
|
||||||
@@ -292,8 +292,8 @@ public class AtomicReference<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An atomic reference to a Kotlin object. Can be used in concurrent scenarious, but must be frozen first,
|
* An atomic reference to a Kotlin object. Can be used in concurrent scenarious, but must be frozen first,
|
||||||
* otherwise behaves as regular box for the value. Asynchronous cycle collector helps to collect the
|
* otherwise behaves as regular box for the value. If frozen, shall be zeroed out once no longer needed.
|
||||||
* cyclic garbage going through frozen instances of `FreezableAtomicReference`.
|
* Otherwise memory leak could happen if atomic reference is a part of a reference cycle.
|
||||||
*/
|
*/
|
||||||
@NoReorderFields
|
@NoReorderFields
|
||||||
@LeakDetectorCandidate
|
@LeakDetectorCandidate
|
||||||
@@ -377,4 +377,4 @@ public class FreezableAtomicReference<T>(private var value_: T) {
|
|||||||
|
|
||||||
@SymbolName("Kotlin_AtomicReference_compareAndSet")
|
@SymbolName("Kotlin_AtomicReference_compareAndSet")
|
||||||
private external fun compareAndSetImpl(expected: Any?, new: Any?): Boolean
|
private external fun compareAndSetImpl(expected: Any?, new: Any?): Boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user