Build update

This commit is contained in:
Alexander Nozik 2025-01-18 13:10:57 +03:00
parent 9d70ba96eb
commit da0ecbe2e5
6 changed files with 15 additions and 8 deletions
CHANGELOG.md
dataforge-context
dataforge-data
build.gradle.kts
src/commonMain/kotlin/space/kscience/dataforge
gradle.properties

@ -4,7 +4,8 @@
### Added
- Coroutine exception logging in context
- ObservableMutableMetaSerializer
- `ObservableMutableMetaSerializer`
- `MutableMetaView` - a Meta wrapper that creates nodes only when its or its children are changed.
### Changed
- Simplify inheritance logic in `MutableTypedMeta`

@ -13,7 +13,7 @@ kscience {
useSerialization()
commonMain {
api(projects.dataforgeMeta)
api(spclibs.atomicfu)
// api(spclibs.atomicfu)
}
jvmMain{
api(kotlin("reflect"))

@ -9,7 +9,7 @@ kscience{
wasm()
useCoroutines()
dependencies {
api(spclibs.atomicfu)
// api(spclibs.atomicfu)
api(projects.dataforgeMeta)
//Remove after subtype moved to stdlib
api(kotlin("reflect"))

@ -37,6 +37,7 @@ public class MapActionBuilder<T, R>(
/**
* Set unsafe [outputType] for the resulting data. Be sure that it is correct.
*/
@UnsafeKType
public fun <R1 : R> result(outputType: KType, f: suspend ActionEnv.(T) -> R1) {
this.outputType = outputType
result = f;
@ -45,6 +46,7 @@ public class MapActionBuilder<T, R>(
/**
* Calculate the result of goal
*/
@OptIn(UnsafeKType::class)
public inline fun <reified R1 : R> result(noinline f: suspend ActionEnv.(T) -> R1): Unit = result(typeOf<R1>(), f)
}

@ -64,11 +64,14 @@ public open class LazyGoal<T>(
/**
* Get ongoing computation or start a new one.
* Does not guarantee thread safety. In case of multi-thread access, could create orphan computations.
* If [GoalExecutionRestriction] is present in the [coroutineScope] context, the call could produce a error a warning
* If [GoalExecutionRestriction] is present in the [coroutineScope] context, the call could produce an error or a warning
* depending on the settings.
*
* If [Goal] is already started on a different scope, it is not restarted.
*/
@OptIn(DFExperimental::class)
override fun async(coroutineScope: CoroutineScope): Deferred<T> {
override fun async(coroutineScope: CoroutineScope): Deferred<T> = deferred ?: run {
val log = coroutineScope.coroutineContext[GoalLogger]
// Check if context restricts goal computation
coroutineScope.coroutineContext[GoalExecutionRestriction]?.let { restriction ->
@ -85,13 +88,14 @@ public open class LazyGoal<T>(
val startedDependencies = dependencies.map { goal ->
goal.async(coroutineScope)
}
return deferred ?: coroutineScope.async(
coroutineScope.async(
coroutineContext
+ CoroutineMonitor()
+ Dependencies(startedDependencies)
+ GoalExecutionRestriction(GoalExecutionRestrictionPolicy.NONE) // Remove restrictions on goal execution
) {
//cancel execution if error encountered in one of dependencies
//cancel execution if error encountered in one of the dependencies
startedDependencies.forEach { deferred ->
deferred.invokeOnCompletion { error ->
if (error != null) this.cancel(CancellationException("Dependency $deferred failed with error: ${error.message}"))

@ -6,4 +6,4 @@ org.gradle.jvmargs=-Xmx4096m
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true
toolsVersion=0.16.1-kotlin-2.1.0
toolsVersion=0.16.0-kotlin-2.1.20-Beta1