Skip to content

Commit

Permalink
remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Feb 23, 2024
1 parent 6ce725b commit 09b58b8
Show file tree
Hide file tree
Showing 57 changed files with 48 additions and 175 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ val compilerOptions = Seq(
"-unchecked",
"-deprecation",
"-language:implicitConversions",
"-Wvalue-discard"
"-Wvalue-discard",
"-Wunused:all"
// "-Xfatal-warnings"
// "-explain"
// "-Vprofile",
)
Expand Down
2 changes: 1 addition & 1 deletion kyo-bench/src/main/scala/kyo/bench/Bench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import zio.UIO
// jvm = "/Users/flavio.brasil/Downloads/graalvm-ce-java17-22.3.0/Contents/Home/bin/java"
)
@BenchmarkMode(Array(Mode.Throughput))
sealed abstract class Bench[T](using f: Flat[T]):
sealed abstract class Bench[T]:
def zioBench(): UIO[T]
def kyoBenchFiber(): T < Fibers = kyoBench()
def kyoBench(): T < IOs
Expand Down
1 change: 0 additions & 1 deletion kyo-bench/src/main/scala/kyo/bench/ForkManyBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class ForkManyBench extends Bench.ForkOnly[Int]:
@Benchmark
def forkOx() =
import ox.*
import ox.channels.*
import java.util.concurrent.CompletableFuture
import java.util.concurrent.atomic.AtomicInteger

Expand Down
1 change: 0 additions & 1 deletion kyo-bench/src/main/scala/kyo/bench/ForkSpawnBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class ForkSpawnBench extends Bench.ForkOnly[Unit]:

def catsBench() =
import cats.effect.IO
import cats.effect.std.Semaphore
import cats.effect.std.CountDownLatch

def repeat[A](n: Int)(io: IO[A]): IO[A] =
Expand Down
1 change: 0 additions & 1 deletion kyo-bench/src/main/scala/kyo/bench/LoggingBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class LoggingBench extends Bench.SyncAndFork[Unit]:

def zioBench() =
import zio.*
import zio.logging.backend.SLF4J

def loop(i: Int): UIO[Unit] =
if i > depth then
Expand Down
1 change: 0 additions & 1 deletion kyo-bench/src/main/scala/kyo/bench/RendezvousBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class RendezvousBench extends Bench.ForkOnly[Int]:

override def kyoBenchFiber() =
import kyo.*
import kyo.*

def produce(waiting: AtomicRef[Any], n: Int = 0): Unit < Fibers =
if n <= depth then
Expand Down
2 changes: 0 additions & 2 deletions kyo-core/js/src/main/scala/kyo/queuesStubs.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.jctools.queues

import java.util.ArrayDeque
import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingDeque

class StubQueue[T](capacity: Int) extends ArrayDeque[T]:
def isFull = size() >= capacity
Expand Down
2 changes: 1 addition & 1 deletion kyo-core/js/src/main/scala/kyo/scheduler/Threads.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kyo.scheduler

import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

object Threads:

Expand All @@ -11,3 +10,4 @@ object Threads:
def apply(name: String, create: Runnable => Thread): ThreadFactory =
new ThreadFactory
end Threads

Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package java.util

import java.util.ArrayList
import java.util.Iterator

class ServiceLoader[T]:
def iterator(): Iterator[T] =
(new ArrayList[T](0)).iterator()
Expand Down
12 changes: 3 additions & 9 deletions kyo-core/jvm/src/main/scala/kyo/scheduler/Coordinator.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package kyo.scheduler

import java.util.concurrent.Executors
import scala.util.Random
import jdk.internal.vm.annotation.Contended
import scala.util.control.NonFatal
import scala.util.control.NonFatal.apply

private object Coordinator:

Expand All @@ -15,13 +14,8 @@ private object Coordinator:
private val cycleTicks = Math.pow(2, cycleExp).intValue()
private val cycleMask = cycleTicks - 1

@volatile private[this] var ticks: Long = 0L

private val a1, a2, a3, a4, a5, a6, a7 = 0L // paddding

@volatile private[this] var cycles = 0L

private val b1, b2, b3, b4, b5, b6, b7 = 0L // paddding
@Contended @volatile private[this] var ticks: Long = 0L
@Contended @volatile private[this] var cycles = 0L

private var startNs = 0L
private val delayNs = new MovingStdDev(cycleExp)
Expand Down
4 changes: 2 additions & 2 deletions kyo-core/jvm/src/main/scala/kyo/scheduler/MovingStdDev.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ final private class MovingStdDev(exp: Int):

private val window = 1 << exp
private val mask = window - 1
private var values = new Array[Long](window)
private var devs = new Array[Long](window)
private val values = new Array[Long](window)
private val devs = new Array[Long](window)
private var idx = 0
private var sum = 0L
private var sumDev = 0L
Expand Down
9 changes: 0 additions & 9 deletions kyo-core/jvm/src/main/scala/kyo/scheduler/Scheduler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ package kyo.scheduler

import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.atomic.LongAdder
import java.util.concurrent.locks.LockSupport
import kyo.*
import kyo.scheduler.Coordinator
import kyo.scheduler.Flag
import kyo.scheduler.IOTask
import kyo.scheduler.Threads
import kyo.scheduler.Worker
import kyo.scheduler.XSRandom
import org.jctools.queues.MpmcUnboundedXaddArrayQueue
import scala.annotation.tailrec

Expand Down
6 changes: 0 additions & 6 deletions kyo-core/jvm/src/main/scala/kyo/scheduler/Worker.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package kyo.scheduler

import java.util.Comparator
import java.util.PriorityQueue
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.Semaphore
import java.util.concurrent.locks.LockSupport
import kyo.iosInternal.*
import kyo.scheduler.IOTask
import kyo.scheduler.Queue
import kyo.scheduler.Scheduler

final private class Worker(r: Runnable)
extends Thread(r):
Expand Down
2 changes: 0 additions & 2 deletions kyo-core/jvm/src/test/scala/kyoTest/MonadLawsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package kyoTest

import kyo.*
import kyo.Flat.unsafe.bypass
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import zio.Trace
import zio.prelude.Equal
import zio.prelude.coherent.CovariantDeriveEqual
Expand Down
17 changes: 13 additions & 4 deletions kyo-core/shared/src/main/scala/kyo/KyoApp.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kyo

import scala.annotation.nowarn
import scala.collection.mutable.ListBuffer
import scala.concurrent.duration.Duration
import scala.util.Try

Expand All @@ -14,15 +14,24 @@ end KyoApp

object KyoApp:

abstract class Base[S] extends App:
abstract class Base[S]:

protected def handle[T](v: T < S)(using f: Flat[T < S]): Unit

@nowarn
final protected def args: Array[String] = _args

private[this] var _args: Array[String] = _

private[this] val initCode = new ListBuffer[() => Unit]

final def main(args: Array[String]) =
this._args = args
for proc <- initCode do proc()

protected def run[T](v: => T < S)(
using f: Flat[T < S]
): Unit =
delayedInit(handle(v))
initCode += (() => handle(v))
end Base

type Effects = Fibers & Resources
Expand Down
3 changes: 1 addition & 2 deletions kyo-core/shared/src/main/scala/kyo/channels.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ end Channel

object Channels:

private val placeholder = Fibers.unsafeInitPromise[Unit]
private val closed = IOs.fail("Channel closed!")
private val closed = IOs.fail("Channel closed!")

def init[T: Flat](
capacity: Int,
Expand Down
16 changes: 10 additions & 6 deletions kyo-core/shared/src/main/scala/kyo/internal/FlatImplicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ object FlatImplicits:
def fail(msg: String) =
report.errorAndAbort(s"Method doesn't accept nested Kyo computations.\n$msg")

def canDerive(t: TypeRepr) =
def derive(t: TypeRepr) =
t.asType match
case '[nt] =>
Expr.summon[Flat[nt]].isDefined
Expr.summon[Flat[nt]]

def isAny(t: TypeRepr) =
t.typeSymbol == TypeRepr.of[Any].typeSymbol
Expand All @@ -55,10 +55,14 @@ object FlatImplicits:
t.typeSymbol.isClassDef

def check(t: TypeRepr): Expr[Flat[T]] =
if isAny(t) || (!isConcrete(t.dealias) && !canDerive(t)) then
fail(
s"Cannot prove ${code(print(t))} isn't nested. Provide an implicit evidence ${code(s"kyo.Flat[${print(t)}]")}."
)
if isAny(t) || !isConcrete(t.dealias) then
derive(t) match
case Some(d) =>
'{ $d.asInstanceOf[Flat[T]] }
case None =>
fail(
s"Cannot prove ${code(print(t))} isn't nested. Provide an implicit evidence ${code(s"kyo.Flat[${print(t)}]")}."
)
else
'{ Flat.unsafe.bypass[T] }

Expand Down
2 changes: 0 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/randoms.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package kyo

import scala.Console

abstract class Random:
def nextInt: Int < IOs
def nextInt(n: Int): Int < IOs
Expand Down
3 changes: 0 additions & 3 deletions kyo-core/shared/src/main/scala/kyo/scheduler/IOPromise.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package kyo.scheduler

import IOPromise.*
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.locks.AbstractQueuedSynchronizer
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.LockSupport
import kyo.*
import kyo.scheduler.Scheduler
import scala.annotation.tailrec
import scala.util.control.NonFatal

Expand Down
3 changes: 1 addition & 2 deletions kyo-core/shared/src/main/scala/kyo/scheduler/IOTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kyo.scheduler

import java.util.ArrayDeque
import java.util.Arrays
import java.util.IdentityHashMap
import kyo.*
import kyo.Locals.State
import kyo.core.*
Expand Down Expand Up @@ -177,6 +176,6 @@ private[kyo] class IOTask[T](
s"[$f]"
case arr: ArrayDeque[() => Unit] @unchecked =>
Arrays.toString(arr.toArray)
s"IOTask(id=${hashCode},preempting=${check()},curr=$curr,ensures=$ensures,runtime=${runtime()},state=${get()})"
s"IOTask(id=${hashCode},preempting=${check()},curr=$curr,ensures=$e,runtime=${runtime()},state=${get()})"
end toString
end IOTask
1 change: 0 additions & 1 deletion kyo-core/shared/src/main/scala/kyo/seqs.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kyo

import kyo.core.*
import scala.collection.mutable.ListBuffer

sealed abstract class Seqs private[kyo] () extends Effect[Seq, Seqs]:

Expand Down
2 changes: 2 additions & 0 deletions kyo-core/shared/src/test/scala/kyoTest/FlatTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FlatTest extends KyoTest:
implicitly[Flat[T < Options]]
implicitly[Flat[T < Any]]
end test1
test1[Int]
succeed
}
"derived" in {
Expand All @@ -30,6 +31,7 @@ class FlatTest extends KyoTest:
implicitly[Flat[T < Options]]
implicitly[Flat[T < Any]]
end test2
test2[Int]
succeed
}
}
Expand Down
5 changes: 0 additions & 5 deletions kyo-core/shared/src/test/scala/kyoTest/KyoTest.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package kyoTest

import izumi.reflect.*
import kyo.*
import org.scalatest.Assertions
import org.scalatest.compatible.Assertion
import org.scalatest.concurrent.ScalaFutures.*
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.freespec.AsyncFreeSpec
import org.scalatest.time.Seconds
import org.scalatest.time.Span
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.concurrent.duration.*
import scala.util.Try

Expand Down
5 changes: 0 additions & 5 deletions kyo-core/shared/src/test/scala/kyoTest/abortsTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package kyoTest

import kyo.*
import org.scalatest.Args
import org.scalatest.Status
import scala.util.Failure
import scala.util.Success
import scala.util.Try

class abortsTest extends KyoTest:

Expand Down
1 change: 0 additions & 1 deletion kyo-core/shared/src/test/scala/kyoTest/clocksTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kyoTest

import java.time.Instant
import java.time.ZoneId
import kyo.*

class clocksTest extends KyoTest:
Expand Down
18 changes: 2 additions & 16 deletions kyo-core/shared/src/test/scala/kyoTest/envsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class envsTest extends KyoTest:
"one service" in {
val a =
Envs[Service1].get.map(_(1))
val b: Int < Envs[Service1] = a
assert(
Envs[Service1].run(service1)(a) ==
2
Expand All @@ -54,16 +53,10 @@ class envsTest extends KyoTest:
)
}
"dependent services" in {
val s1 = Envs[Service2].get.map(service2 =>
new Service1:
def apply(i: Int) = service2(i * 10)
)
val v1: Service1 < Envs[Service2] = s1
val v2 =
val v1 =
Envs[Service1].run[Int, Envs[Service2]](service1)(v)
val v3: Int < Envs[Service2] = v2
assert(
Envs[Service2].run(service2)(v3) ==
Envs[Service2].run(service2)(v1) ==
4
)
}
Expand All @@ -90,7 +83,6 @@ class envsTest extends KyoTest:
"continue" in {
val a =
Envs[Service1].get.map(_(1))
val b: Int < (Envs[Service1] & Options) = a
assert(
Options.run(Envs[Service1].run(service1)(a)) ==
Some(2)
Expand All @@ -99,7 +91,6 @@ class envsTest extends KyoTest:
"short circuit" in {
val a =
Envs[Service1].get.map(_(0))
val b: Int < (Envs[Service1] & Options) = a
assert(
Options.run(Envs[Service1].run(service1)(a)) ==
None
Expand Down Expand Up @@ -130,11 +121,6 @@ class envsTest extends KyoTest:
)
}
"dependent services" in {
val s1 = Envs[Service2].get.map(service2 =>
new Service1:
def apply(i: Int) = service2(i * 10)
)
val v1: Service1 < Envs[Service2] = s1
val v2: Int < (Envs[Service2] & Options) = Envs[Service1].run(service1)(v)
assert(
Options.run(Envs[Service2].run(service2)(v2)) ==
Expand Down
Loading

0 comments on commit 09b58b8

Please sign in to comment.