v0.9 preparations. (#1962)

This commit is contained in:
Nikolay Igotti
2018-08-29 19:35:59 +03:00
committed by GitHub
parent 96b6645f2e
commit 838956f4df
4 changed files with 21 additions and 4 deletions
+8 -1
View File
@@ -15,10 +15,17 @@ 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, `konan.ThreadLocal` annotation could be used, which will make
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
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.
Class `AtomicReference` could be used to publish changed frozen state to
other threads, and thus build patterns like shared caches.