Align docs with USE_CYCLIC_GC=0 (ed36f02c)

Co-authored-by: ilya-g <ilya.gorbunov@jetbrains.com>
This commit is contained in:
SvyatoslavScherbina
2020-05-18 19:34:47 +03:00
committed by GitHub
parent 3c2b742ba9
commit db9361f8a2
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -199,10 +199,10 @@ To achieve such functionality Kotlin/Native runtime provides two related classes
`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
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
Kotlin/Native runtime has special concurrent cycle collector, concurrently analyzing cyclic data rooted in atomic references.
When cycle of no longer used objects is detected, collector zeroes out reference stored in atomic reference and thus
allows cycle to be collected.
(of immutable objects). Cycles in the shared memory could be created using atomic references.
Kotlin/Native runtime doesn't support garbage collecting cyclic data when reference cycle goes through
`AtomicReference` or frozen `FreezableAtomicReference`. So to avoid memory leaks atomic references
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.
@@ -216,7 +216,7 @@ private fun debugString(value: Any?): String {
/**
* 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.
* 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
@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,
* otherwise behaves as regular box for the value. Asynchronous cycle collector helps to collect the
* cyclic garbage going through frozen instances of `FreezableAtomicReference`.
* otherwise behaves as regular box for the value. If frozen, shall be zeroed out once no longer needed.
* Otherwise memory leak could happen if atomic reference is a part of a reference cycle.
*/
@NoReorderFields
@LeakDetectorCandidate
@@ -377,4 +377,4 @@ public class FreezableAtomicReference<T>(private var value_: T) {
@SymbolName("Kotlin_AtomicReference_compareAndSet")
private external fun compareAndSetImpl(expected: Any?, new: Any?): Boolean
}
}