Skip to content

Commit

Permalink
make shared variables volatile in loom test
Browse files Browse the repository at this point in the history
  • Loading branch information
rssh committed Mar 30, 2024
1 parent ec99345 commit 17b4c8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class PhaseSelectAndGenerateShiftedMethods(selectedNodes: SelectedNodes) extends
}

// generate shifted version for hight-order functions annotated by makeCPS
override def transformTemplate(tree: tpd.Template)(using Context): tpd.Tree = {
println(s"transformTemplate: ${tree.symbol}")
override def transformTemplate(tree: tpd.Template)(using Context): tpd.Tree = {
val makeCpsAnnot = Symbols.requiredClass("cps.plugin.annotation.makeCPS")
val shiftedMethods = tree.body.filter(_.symbol.annotations.exists(_.symbol == makeCpsAnnot))
.flatMap { m =>
Expand Down
9 changes: 5 additions & 4 deletions compiler-plugin/testdata/set18loom/m3/TestPME.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ object PoorManEffect {
case Success(t) => cf.complete(t)
case Failure(e) => cf.completeExceptionally(e)
case None =>
throw new IllegalArgumentException(s"invalid submitId=${id}")
}


def process(): Unit = {
var blocked: Boolean = false
var finished: Boolean = false
//println(s"starting process thread ${Thread.currentThread().getId()}")
@volatile var blocked: Boolean = false
@volatile var finished: Boolean = false
processEntryCounter.incrementAndGet()
BlockContext.withBlockContext(
new BlockContext {
Expand Down Expand Up @@ -168,9 +170,7 @@ object PoorManEffect {
while (!finished && !blocked) {
while(runQueue.isEmpty && !blocked && nThunksInProcess.get() > 0) {
submitWaiter.synchronized {
if (runQueue.isEmpty && !blocked && nThunksInProcess.get() > 0) {
submitWaiter.wait()
}
}
}
while (!runQueue.isEmpty && !blocked) {
Expand Down Expand Up @@ -207,6 +207,7 @@ object PoorManEffect {
}
}
processEntryCounter.decrementAndGet()
//println(s"exiting process thread ${Thread.currentThread().getId()} blocked=${blocked}")
}

}
Expand Down

0 comments on commit 17b4c8d

Please sign in to comment.