From 838956f4dfbc2d55dd7f9315a1c2b5554c40aabf Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Wed, 29 Aug 2018 19:35:59 +0300 Subject: [PATCH] v0.9 preparations. (#1962) --- CHANGELOG.md | 10 ++++++++++ IMMUTABILITY.md | 9 ++++++++- INTEROP.md | 4 ++-- .../main/kotlin/kotlin/native/internal/RuntimeUtils.kt | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8aa1bc6d61..2f33a36de2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# v0.9 (Sep 2018) + * Support Kotlin 1.3M2 + * Major standard library (native parts) rework and rename + * New Gradle plugin with multiplatform integration and reworked DSL + * Support unsigned types in Kotlin and interop + * Support non-experimental coroutines API (kotlin.coroutines) + * Top level object var/val can only be accessed from the main thread + * Support lazy properties in singleton objects + * Update LLVM to 6.0.1 + ## v0.8 (Jul 2018) * Singleton objects are frozen after creation, and shared between threads * String and primitives types are frozen by default diff --git a/IMMUTABILITY.md b/IMMUTABILITY.md index 4c36a2a946a..e8433df3ff8 100644 --- a/IMMUTABILITY.md +++ b/IMMUTABILITY.md @@ -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. diff --git a/INTEROP.md b/INTEROP.md index af7f9a5212b..c78a160f19a 100644 --- a/INTEROP.md +++ b/INTEROP.md @@ -389,8 +389,8 @@ Note that some function types are not supported currently. For example, it is not possible to get pointer to function that receives or returns structs by value. -If the callback doesn't run in the main thread it is mandatory to init the konan runtime -by calling `konan.initRuntimeIfNeeded()`. +If the callback doesn't run in the main thread it is mandatory to init the _Kotlin/Native_ +runtime by calling `kotlin.native.initRuntimeIfNeeded()`. #### Passing user data to callbacks #### diff --git a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index 49f7b57b23c..d0843b3edb3 100644 --- a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -73,7 +73,7 @@ internal fun ThrowIllegalCharacterConversionException(): Nothing { @ExportForCppRuntime internal fun ThrowIncorrectDereferenceException() { throw IncorrectDereferenceException( - "Trying to access top level value not marked as @ThreadLocal or @ImmutableShared from non-main thread") + "Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread") } @ExportForCppRuntime