diff --git a/jcstress/.gitignore b/jcstress/.gitignore index 2f7896d..4c72a9b 100644 --- a/jcstress/.gitignore +++ b/jcstress/.gitignore @@ -1 +1,2 @@ target/ +libs/ diff --git a/jcstress/pom.xml b/jcstress/pom.xml index 2f4ed29..012c16e 100644 --- a/jcstress/pom.xml +++ b/jcstress/pom.xml @@ -55,6 +55,11 @@ THE POSSIBILITY OF SUCH DAMAGE. jcstress-core ${jcstress.version} + + komem.litmus + litmuskt + 1.0 + @@ -115,6 +120,29 @@ THE POSSIBILITY OF SUCH DAMAGE. + + + org.apache.maven.plugins + maven-install-plugin + 3.1.1 + + komem.litmus + litmuskt + 1.0 + jar + ${basedir}/libs/litmus-jvm-1.0-SNAPSHOT.jar + true + + + + install-jar-lib + + install-file + + validate + + + diff --git a/jcstress/src/main/java/org/sample/AbaTest.java b/jcstress/src/main/java/org/sample/AbaTest.java new file mode 100644 index 0000000..6c05b03 --- /dev/null +++ b/jcstress/src/main/java/org/sample/AbaTest.java @@ -0,0 +1,15 @@ +package org.sample; + +import komem.litmus.LitmusTest; + +public class AbaTest { + + private List> fs; + private Function1 arbiter; + + public AbaTest(LitmusTest test) { + fs = test.getThreadFunctions(); + arbiter = test.getOutcomeFinalizer(); + } + +} diff --git a/jcstress/src/main/java/org/sample/ConcurrencyTest.java b/jcstress/src/main/java/org/sample/ConcurrencyTest.java index fa2664a..344e215 100644 --- a/jcstress/src/main/java/org/sample/ConcurrencyTest.java +++ b/jcstress/src/main/java/org/sample/ConcurrencyTest.java @@ -33,6 +33,8 @@ import org.openjdk.jcstress.annotations.*; import org.openjdk.jcstress.infra.results.II_Result; +import komem.litmus.AffinityMap; + // See jcstress-samples or existing tests for API introduction and testing guidelines @JCStressTest @@ -43,7 +45,7 @@ public class ConcurrencyTest { @Actor public void actor1(II_Result r) { - // Put the code for first thread here + } @Actor diff --git a/litmus/build.gradle.kts b/litmus/build.gradle.kts index 2f3ef02..0b1f60a 100644 --- a/litmus/build.gradle.kts +++ b/litmus/build.gradle.kts @@ -4,6 +4,7 @@ import org.jetbrains.kotlin.incremental.createDirectory plugins { kotlin("multiplatform") id("com.google.devtools.ksp") version "1.9.10-1.0.13" + `java-library` } group = "komem.litmus" @@ -34,6 +35,8 @@ kotlin { mainRun { mainClass.set("JvmMainKt") } + withSourcesJar() + withJava() } val affinitySupported = hostOs == "Linux" @@ -153,3 +156,9 @@ tasks.whenTaskAdded { tasks.matching { it.name.startsWith("compileKotlin") }.forEach { it.dependsOn(kspTask) } } } + +tasks.register("copyLibToJCStress") { + dependsOn("jvmJar") + from(buildDir.resolve("libs/litmus-jvm-$version.jar")) + into(projectDir.resolve("../jcstress/libs/")) +} diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt b/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt index bd04a6a..7f8bad3 100644 --- a/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt +++ b/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt @@ -2,7 +2,7 @@ package komem.litmus data class LitmusTest( val stateProducer: () -> S, - val threadFunctions: List Any?>, + val threadFunctions: List Unit>, val outcomeFinalizer: (S.() -> LitmusOutcome), val outcomeSpec: LitmusOutcomeSpec ) { @@ -12,7 +12,7 @@ data class LitmusTest( class LitmusTestScope( private val stateProducer: () -> S ) { - private val threadFunctions = mutableListOf Any?>() + private val threadFunctions = mutableListOf Unit>() private lateinit var outcomeFinalizer: S.() -> LitmusOutcome private lateinit var outcomeSpec: LitmusOutcomeSpecScope diff --git a/litmus/src/jvmMain/java/AbaTest.java b/litmus/src/jvmMain/java/AbaTest.java new file mode 100644 index 0000000..3834d63 --- /dev/null +++ b/litmus/src/jvmMain/java/AbaTest.java @@ -0,0 +1,31 @@ +import komem.litmus.LitmusTest; +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + +import java.util.List; + +public class AbaTest { + + private static List> fs; + private static Function1 arbiter; + + public AbaTest(LitmusTest test) { + fs = test.getThreadFunctions(); + arbiter = test.getOutcomeFinalizer(); + } + +} + + +/* + +class LitmusJcsState { + private static (!!!) List> tfs = test.getThreadFunctions(); + + private S state = stateProducer(); + + public void actor0() { + tfs[0].invoke(state); + } +} + */ diff --git a/litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt b/litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt index afed7f8..1c05a4c 100644 --- a/litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt +++ b/litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt @@ -10,6 +10,6 @@ class NativeTest { val test = ATOM val runner = WorkerRunner val params = LitmusRunParams(1_000_000, 100, null, ::CinteropSpinBarrier) - runner.runTest(params, test).prettyPrint() + runner.runTest(params, test) } }