From 985385e2fac037a1e9d8f2253139fced195c7421 Mon Sep 17 00:00:00 2001 From: Watson David <30525704+B1ggDave@users.noreply.github.com> Date: Thu, 13 Sep 2018 10:48:43 +0200 Subject: [PATCH] Proofread Watson (#2055) --- IMMUTABILITY.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/IMMUTABILITY.md b/IMMUTABILITY.md index e8433df3ff8..746610d084a 100644 --- a/IMMUTABILITY.md +++ b/IMMUTABILITY.md @@ -1,31 +1,31 @@ # Immutability in Kotlin/Native Kotlin/Native implements strict mutability checks, ensuring -important invariant that object is either immutable or -accessible from the single thread at the moment (`mutable XOR global`). +the important invariant that the object is either immutable or +accessible from the single thread at that moment in time (`mutable XOR global`). - Immutability is the runtime property in Kotlin/Native, and can be applied -to an arbitrary object subgraph using `kotlin.native.concurrent.freeze` function. -It makes all objects reachable from the given one immutable, and -such a transition is a one way operation (object cannot be unfrozen later). -Some naturally immutable objects, such as `kotlin.String`, `kotlin.Int` and + Immutability is a runtime property in Kotlin/Native, and can be applied +to an arbitrary object subgraph using the `kotlin.native.concurrent.freeze` function. +It makes all the objects reachable from the given one immutable, +such a transition is a one-way operation (i.e., objects cannot be unfrozen later). +Some naturally immutable objects such as `kotlin.String`, `kotlin.Int`, and other primitive types, along with `AtomicInt` and `AtomicReference` are frozen -by default. If mutating operation is applied to a frozen object, +by default. If a mutating operation is applied to a frozen object, an `InvalidMutabilityException` is thrown. - To achieve `mutable XOR global` invariant all globally visible state (currently, -`object` singletons and enums) are automatically frozen. If an object freezing -is not desirable, `kotlin.native.ThreadLocal` annotation could be used, which will make -object state thread local, and thus, mutable (but changed state not visible to + To achieve `mutable XOR global` invariant, all globally visible state (currently, +`object` singletons and enums) are automatically frozen. If object freezing +is not desired, a `kotlin.native.ThreadLocal` annotation can be used, which will make +the object state thread local, and so, mutable (but the changed state is not visible to other threads). Top level/global variables of non-primitive types are by default accessible in the -main thread (i.e. thread which initialized _Kotlin/Native_ runtime first) only. -Access from another thread leads to an `IncorrectDereferenceException` being thrown. -To make such variables accessible in other threads either `@ThreadLocal` annotation, -marking value thread local or `@SharedImmutable`, making value frozen, and accessible -from other threads, can be used. +main thread (i.e., the thread which initialized _Kotlin/Native_ runtime first) only. +Access from another thread will lead to an `IncorrectDereferenceException` being thrown. +To make such variables accessible in other threads, you can use either the `@ThreadLocal` annotation, +and mark the value thread local or `@SharedImmutable`, which will make the value frozen and accessible +from other threads. - Class `AtomicReference` could be used to publish changed frozen state to -other threads, and thus build patterns like shared caches. + Class `AtomicReference` can be used to publish the changed frozen state to +other threads, and so build patterns like shared caches.