Skip to content

Commit

Permalink
remove some old aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Mar 2, 2024
1 parent 67a19c1 commit a48dc99
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import java.awt.{Color, Graphics2D}
import examples.demo.Pos
import reactives.core.AdmissionTicket
import reactives.default.*
import reactives.default.global.State as BundleState


trait Shape extends Serializable {
val changed: Event[Any]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package examples.demo.ui

import reactives.default.{*}
import reactives.default.*

import java.awt.event.*
import java.awt.{Event as _, Shape as _, *}
Expand All @@ -16,7 +16,7 @@ class ShapesPanel(val shapes: Signal[Iterable[Shape]]) extends Panel {
allChanges observe { _ => repaint() }

override def paintComponent(g: Graphics2D): Unit = {
scheduler.forceNewTransaction() { implicit turn =>
global.scheduler.forceNewTransaction() { implicit turn =>
g.setColor(Color.WHITE)
g.fillRect(0, 0, size.width, size.height)
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ object Universe {

val genCsv = !args.headOption.contains("nocsv")

println(s"profiling ${reactives.default.scheduler.schedulerName}")
println(s"profiling ${reactives.default.global.scheduler.schedulerName}")

val outfile = s"universe-${reactives.default.scheduler.schedulerName}.csv"
val outfile = s"universe-${reactives.default.global.scheduler.schedulerName}.csv"

if genCsv then
Files.write(
Expand Down Expand Up @@ -45,7 +45,7 @@ object Universe {
if (repetition > 0 && genCsv) {
Files.write(
Paths.get(outfile),
s"""$repetition,$duration,"${reactives.default.scheduler.schedulerName}","UniverseCaseStudy",$height,$width,$nAnimals,$nPlants${"\n"}""".getBytes(),
s"""$repetition,$duration,"${reactives.default.global.scheduler.schedulerName}","UniverseCaseStudy",$height,$width,$nAnimals,$nPlants${"\n"}""".getBytes(),
StandardOpenOption.APPEND
)
()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package reactives.todo

import reactives.core.{CreationTicket, Derived, DynamicTicket, ReInfo, ReadAs}
import reactives.default.*
import reactives.default.global.State as BundleState


case class DeltaWithState[Delta, DState](delta: Seq[Delta], state: DState)

Expand All @@ -13,7 +15,7 @@ class DeltaStateReactive[Delta, Combined](
override val info: ReInfo,
) extends Derived with ReadAs[DeltaWithState[Delta, Combined]] {
override type Value = DeltaWithState[Delta, Combined]
override type State[V] = reactives.default.BundleState[V]
override type State[V] = BundleState[V]
override protected[reactives] def state: State[Value] = initState
override protected[reactives] def commit(base: Value): Value = base.copy(delta = Nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import reactives.default.*
import com.github.plokhotnyuk.jsoniter_scala.core.*
import reactives.core.ReSource
import reactives.operator.Events
import reactives.default.global.State as BundleState

trait RemoteGraph {
protected var connector: Option[RemoteGraphConnector] = None
Expand Down
2 changes: 2 additions & 0 deletions Modules/Graph-Compiler/src/main/scala/api2/TupleUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package api2

import reactives.core.StaticTicket
import reactives.default.*
import reactives.default.global.State as BundleState


type CEventsFromEvents[T <: Tuple] <: Tuple = T match
case EmptyTuple => EmptyTuple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import reactives.operator.Interface

import java.util.concurrent.TimeUnit
import java.util.concurrent.locks.{ReadWriteLock, ReentrantReadWriteLock}
import reactives.default.global.State as BundleState


@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
Expand All @@ -19,7 +21,7 @@ class SingleVar {

var engine: Interface = scala.compiletime.uninitialized
final lazy val engineT = engine
implicit def scheduler: Scheduler[engineT.BundleState] = engineT.scheduler
implicit def scheduler: Scheduler[engineT.global.State] = engineT.global.scheduler

var source: engineT.Var[Boolean] = scala.compiletime.uninitialized
var current: Boolean = scala.compiletime.uninitialized
Expand All @@ -30,7 +32,7 @@ class SingleVar {
engine = engineParam.engine
current = false
source = engineT.Var(current)
if (engineParam.engine.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) lock = new ReentrantReadWriteLock()
if (engineParam.engine.global.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) lock = new ReentrantReadWriteLock()
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ChatBench {
@Benchmark
def chat(benchState: BenchState, threadParams: ThreadParams) = {
import benchState.stableEngine._
if (scheduler != reactives.scheduler.LevelbasedVariants.unmanaged) {
if (global.scheduler != reactives.scheduler.LevelbasedVariants.unmanaged) {
benchState.clients(threadParams.getThreadIndex).fire("hello")
} else {
val ti = threadParams.getThreadIndex
Expand Down Expand Up @@ -68,7 +68,7 @@ class BenchState {
cs.histories.get(room2).observe(v => work.consume())
}

if (engine.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) {
if (engine.global.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) {
locks = Array.fill(size.size)(new ReentrantLock())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SingleSwitch {
if (step.test(source.value)) d1.value else d2.value
}

if (engine.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) isManual = true
if (engine.global.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) isManual = true

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StackState {
def setup(params: BenchmarkParams, eParam: EngineParam, work: Workload, size: Size, step: Step) = {
engine = eParam.engine
val threads = params.getThreads
if (scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) { isManual = true }
if (engine.global.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) { isManual = true }
sources = Range(0, threads).map(_ => Var(0)).toArray
results = sources.map { source =>
var cur: Signal[Int] = source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package benchmarks.philosophers
import reactives.core.{CreationTicket, ReInfo, ReSource}
import reactives.operator.Interface
import reactives.parrp.Backoff
import reactives.default.global.State as BundleState


import java.util.concurrent.locks.ReentrantLock
import java.util.concurrent.{Executors, ThreadLocalRandom}
Expand Down Expand Up @@ -196,7 +198,7 @@ trait NoTopper extends IndividualCounts {
}
}

override def total: Int = individualCounts.map(_.readValueOnce(engine.scheduler)).sum
override def total: Int = individualCounts.map(_.readValueOnce(engine.global.scheduler)).sum
}

trait SignalPyramidTopper extends IndividualCounts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PhilosopherCompetition {

def tryUpdateCycle(comp: Competition)(seating: comp.stableTable.Seating): Boolean = {
val res = comp.stableTable.tryEat(seating)
if (res) seating.philosopher.set(Thinking)(using comp.stableTable.engine.scheduler)
if (res) seating.philosopher.set(Thinking)(using comp.stableTable.engine.global.scheduler)
!res
}

Expand Down Expand Up @@ -70,7 +70,7 @@ class PhilosopherCompetition {
thirdLock.lock()
try {
seating.philosopher.set(Thinking)(
using comp.stableTable.engine.scheduler,
using comp.stableTable.engine.global.scheduler,
)
} finally { thirdLock.unlock() }
} finally { secondLock.unlock() }
Expand Down Expand Up @@ -128,7 +128,7 @@ class Competition extends BusyThreads {
stableTable.seatings.foreach { seat =>
val phil: stableTable.engine.Var[Philosopher] = seat.philosopher
phil.set(Thinking)(
using stableTable.engine.scheduler,
using stableTable.engine.global.scheduler,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class MultiReverseFan {
@Benchmark
def run(step: Step, params: ThreadParams): Unit = {
val index = params.getThreadIndex
if (locks == null) sources(index).set(step.run())(using scheduler)
if (locks == null) sources(index).set(step.run())(using global.scheduler)
else {
locks(index / groupSize).lock()
try {
sources(index).set(step.run())(using scheduler)
sources(index).set(step.run())(using global.scheduler)
} finally locks(index / groupSize).unlock()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ class NaturalGraph {
}

@Benchmark
def run(step: Step): Unit = source.set(step.run())(using scheduler)
def run(step: Step): Unit = source.set(step.run())(using global.scheduler)

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class ReverseFan {
result = Signal.lift(intermediate.toSeq) { values =>
work.consumeSecondary(); values.sum
}
if (engine.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) isManual = true
if (engine.global.scheduler == reactives.scheduler.LevelbasedVariants.unmanaged) isManual = true

}

@Benchmark
def run(step: Step, params: ThreadParams): Unit =
if (isManual) synchronized {
sources(params.getThreadIndex).set(step.run())(using scheduler)
sources(params.getThreadIndex).set(step.run())(using global.scheduler)
}
else sources(params.getThreadIndex).set(step.run())(using scheduler)
else sources(params.getThreadIndex).set(step.run())(using global.scheduler)
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ReactorWithoutAPITest extends RETests {

def resource: ReadAs.of[State, T] = this

def now: T = scheduler.forceNewTransaction(this)(at => at.now(this))
def now: T = global.scheduler.forceNewTransaction(this)(at => at.now(this))
}

/** A class that manages a single stage of the reactor body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EvaluationOrderWithHigherOrderSignalsTest extends RETests {
}

// final value should be correct
assert(flatten.readValueOnce(scheduler) == newX)
assert(flatten.readValueOnce(global.scheduler) == newX)
// value should be determined by reevaluating twice after discovering a higher-level dependency on first run
reevaluationRestartTracker
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class PhilosopherTable(philosopherCount: Int)(val interface: Interface) {
rightFork: Signal[Fork],
vision: Signal[Vision]
) {
def inspect(t: Transaction[BundleState]): String =
def inspect(t: Transaction[global.State]): String =
s"Seating(${t.now(philosopher)}, ${t.now(leftFork)}, ${t.now(rightFork)}, ${t.now(vision)})"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import reactives.fullmv.tasks.{Framing, Notification, Reevaluation, SupersedeFra
import reactives.fullmv.State

class DeframeTest extends munit.FunSuite {
if reactives.default.scheduler.isInstanceOf[FullMVEngine] then {
if reactives.default.global.scheduler.isInstanceOf[FullMVEngine] then {
import reactives.default.*

implicit def assumeSignalsAreFullMV(sig: ReSource): ReSource.of[State] = sig.asInstanceOf

val engine: FullMVEngine = reactives.default.scheduler.asInstanceOf[FullMVEngine]
val engine: FullMVEngine = reactives.default.global.scheduler.asInstanceOf[FullMVEngine]

test("deframe") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import reactives.fullmv.{FullMVEngine, State}
import tests.rescala.testtools.{IgnoreOnGithubCiBecause, Spawn}

class PipeliningTest extends munit.FunSuite {
if reactives.default.scheduler.isInstanceOf[FullMVEngine] then {
if reactives.default.global.scheduler.isInstanceOf[FullMVEngine] then {
import reactives.default.*

implicit def assumeSignalsAreFullMV(sig: ReSource): ReSource.of[State] = sig.asInstanceOf

val engine: FullMVEngine = reactives.default.scheduler.asInstanceOf[FullMVEngine]
val engine: FullMVEngine = reactives.default.global.scheduler.asInstanceOf[FullMVEngine]
// IgnoreOnGithubCiBecause("pipelining does not work")
test("pipelining works") {
val millisecondsPerNode = 10L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ trait Transaction[State[_]] {
@implicitNotFound(msg = "Could not find an implicit scheduler. Did you forget an import?")
trait Scheduler[S[_]] {

type SchedulerState[T] = S[T]

final def forceNewTransaction[R](initialWrites: ReSource.of[S]*)(admissionPhase: AdmissionTicket[S] => R): R = {
forceNewTransaction(initialWrites.toSet, admissionPhase)
}
Expand All @@ -376,9 +374,10 @@ trait Scheduler[S[_]] {
def dynamicScope: DynamicScope[S]
}
object Scheduler {
given defaultScheduler: Scheduler[Interface.State] = Interface.default
given implicitScheduler: Scheduler[reactives.default.global.State] = reactives.default.global.scheduler
}


trait SchedulerImpl[State[_], Tx <: Transaction[State]] extends Scheduler[State] {
override def dynamicScope: DynamicScopeImpl[State, Tx] = new DynamicScopeImpl[State, Tx](this)
}
Expand All @@ -390,6 +389,9 @@ trait DynamicScope[State[_]] {
}

object DynamicScope {

given implicitDynamicScope: DynamicScope[reactives.default.global.State] = reactives.default.global.dynamicScope

class DynamicScopeImpl[State[_], Tx <: Transaction[State]](scheduler: SchedulerImpl[State, Tx])
extends DynamicScope[State] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object CreationScope {
}

inline given search(using ts: TransactionScope[Interface.State]): CreationScope[Interface.State] = ts.static match
case None => DynamicCreationScope(Interface.default.dynamicScope)
case None => DynamicCreationScope(reactives.default.global.dynamicScope)
case Some(tx) => StaticCreationScope(tx)
}

Expand Down Expand Up @@ -79,6 +79,6 @@ object PlanTransactionScope {

inline given search(using ts: TransactionScope[Interface.State]): PlanTransactionScope[Interface.State] =
ts.static match
case None => DynamicTransactionLookup(Interface.default)
case Some(tx) => StaticInTransaction(tx, Interface.default)
case None => DynamicTransactionLookup(reactives.default.global.scheduler)
case Some(tx) => StaticInTransaction(tx, reactives.default.global.scheduler)
}
Loading

0 comments on commit a48dc99

Please sign in to comment.