.libv1> builtins.merge
test1: Nat -> Nat
test1 n = n + n
| import java.util.concurrent.atomic.AtomicReference; | |
| import java.util.concurrent.locks.LockSupport; | |
| public class Rendezvous { | |
| private final int spinIterations; | |
| private final int yieldIterations; | |
| private final AtomicReference<ThreadAndCell> waiting = new AtomicReference<>(); | |
| public Rendezvous(int spinIterations, int yieldIterations) { | |
| this.spinIterations = spinIterations; |
| import java.util.concurrent.Exchanger; | |
| import java.util.concurrent.SynchronousQueue; | |
| public class RendezvousUsingExchanger { | |
| public static void test() throws Exception { | |
| long startTime = System.currentTimeMillis(); | |
| final int max = 10_000_000; | |
| Exchanger<Integer> data = new Exchanger<>(); | |
| Thread t1 = Thread.ofVirtual().start(() -> { |
| import java.util.concurrent.atomic.AtomicReference; | |
| import java.util.concurrent.locks.LockSupport; | |
| // -Djdk.virtualThreadScheduler.parallelism=1 -Djdk.virtualThreadScheduler.maxPoolSize=1 -Djdk.virtualThreadScheduler.minRunnable=1 | |
| public class Rendezvous { | |
| private final int spinIterations; | |
| private final int yieldIterations; | |
| private final AtomicReference<ThreadAndCell> waiting = new AtomicReference<>(); | |
| public Rendezvous(int spinIterations, int yieldIterations) { |
| import java.util.concurrent.atomic.AtomicReference; | |
| import java.util.concurrent.locks.LockSupport; | |
| public class Rendezvous { | |
| private final boolean yieldOnFirstIteration; | |
| private final AtomicReference<ThreadAndCell> waiting = new AtomicReference<>(); | |
| public Rendezvous(boolean yieldOnFirstIteration) { | |
| this.yieldOnFirstIteration = yieldOnFirstIteration; | |
| } |
| //> using dep com.softwaremill.ox::core:0.0.7 | |
| import ox.* | |
| import ox.channels.* | |
| import scala.annotation.tailrec | |
| scoped { | |
| // fast producer | |
| val c = Channel[Int]() | |
| fork { |
.libv1> builtins.merge
test1: Nat -> Nat
test1 n = n + n
| package sttp.tapir.examples | |
| import cats.effect.{ExitCode, IO, IOApp} | |
| import org.http4s.HttpRoutes | |
| import org.http4s.blaze.server.BlazeServerBuilder | |
| import org.http4s.server.Router | |
| import sttp.model.{Part, StatusCode} | |
| import sttp.model.headers.WWWAuthenticateChallenge | |
| import sttp.tapir._ | |
| import sttp.tapir.generic.auto._ |
| package sttp.tapir.examples | |
| import akka.actor.ActorSystem | |
| import akka.http.scaladsl.Http | |
| import akka.http.scaladsl.server.Route | |
| import scala.concurrent.{Await, Future} | |
| import scala.concurrent.duration._ | |
| import scala.io.StdIn |
| // TestMacro.scala | |
| import scala.quoted.* | |
| object TestMacro { | |
| inline def name[E](e: E): String = ${ nameImpl[E]('e) } | |
| def nameImpl[E: Type](e: Expr[E])(using Quotes): Expr[String] = { | |
| import quotes.reflect.* |
| object UsingIO: | |
| trait Connection | |
| trait User | |
| case class IO[-R, +A](): | |
| def *>[R1 <: R, B](that: => IO[R1, B]): IO[R1, B] = IO() | |
| def foo(): IO[Connection, Unit] = IO() | |
| def bar(): IO[User, Unit] = IO() |