test("what is a cSCC?") {
for (_ <- (1 to 1).seq) {
val latch = new CountDownLatch(1)
val k = new DefaultKey[Int]
val lattice = new NaturalNumberLattice
val pool = new HandlerPoolInt
val completer1 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer2 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer3 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer4 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
//
//
// / ------------v
// 4 <---- 1 2
// ^^-------------/
// |
// |
// 3
//
completer1.cell.when(forwardAsNext, completer2.cell)
completer2.cell.when(forwardAsNext, completer1.cell)
completer3.cell.when(upd => {
println("cell3 informed with " + upd.head.2)
NextOutcome(10)
}, completer1.cell)
//completer1.cell.when(forwardAsNext, completer4.cell)
completer1.putNext(5)
Await.ready(pool.quiescentResolveCell, 2.seconds)
pool.onQuiescent(() => latch.countDown())
latch.await()
// assert(completer1.cell.isComplete)
// assert(completer2.cell.isComplete)
// assert(completer1.cell.getResult() == 5)
// assert(completer2.cell.getResult() == 5)
for ((c, i) <- List(completer1, completer2, completer3, completer4).map(.cell).zipWithIndex) {
println(i + 1, c, c.isComplete, c.getResult())
}
}
test("what is a cSCC?") {
for (_ <- (1 to 1).seq) {
val latch = new CountDownLatch(1)
val k = new DefaultKey[Int]
val lattice = new NaturalNumberLattice
val pool = new HandlerPoolInt
val completer1 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer2 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer3 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
val completer4 = mkCompleter[Int](Updater.latticeToUpdater(lattice), pool)
//
//
// / ------------v
// 4 <---- 1 2
// ^^-------------/
// |
// |
// 3
//
completer1.cell.when(forwardAsNext, completer2.cell)
completer2.cell.when(forwardAsNext, completer1.cell)
completer3.cell.when(upd => {
println("cell3 informed with " + upd.head.2)
NextOutcome(10)
}, completer1.cell)
//completer1.cell.when(forwardAsNext, completer4.cell)
completer1.putNext(5)
Await.ready(pool.quiescentResolveCell, 2.seconds)
pool.onQuiescent(() => latch.countDown())
latch.await()
// assert(completer1.cell.isComplete)
// assert(completer2.cell.isComplete)
// assert(completer1.cell.getResult() == 5)
// assert(completer2.cell.getResult() == 5)
for ((c, i) <- List(completer1, completer2, completer3, completer4).map(.cell).zipWithIndex) {
println(i + 1, c, c.isComplete, c.getResult())
}
}