Remove @inline annotations and enable Scala 2 inliner
This commit is contained in:
parent
d829637ef2
commit
8cb7d256dc
34 changed files with 254 additions and 78 deletions
|
|
@ -44,7 +44,7 @@ object ActorTestKit {
|
|||
* using default configuration from the reference.conf resources that ship with the Akka libraries.
|
||||
* The application.conf of your project is not used in this case.
|
||||
*/
|
||||
def create(): ActorTestKit =
|
||||
@noinline def create(): ActorTestKit =
|
||||
new ActorTestKit(scaladsl.ActorTestKit(TestKitUtils.testNameFromCallStack(classOf[ActorTestKit])))
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +83,7 @@ object ActorTestKit {
|
|||
* When the test has completed you should terminate the `ActorSystem` and
|
||||
* the testkit with [[ActorTestKit#shutdownTestKit]].
|
||||
*/
|
||||
def create(customConfig: Config): ActorTestKit =
|
||||
@noinline def create(customConfig: Config): ActorTestKit =
|
||||
new ActorTestKit(scaladsl.ActorTestKit(TestKitUtils.testNameFromCallStack(classOf[ActorTestKit]), customConfig))
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ final class TestKitJunitResource(_kit: ActorTestKit) extends ExternalResource {
|
|||
* using default configuration from the reference.conf resources that ship with the Akka libraries.
|
||||
* The application.conf of your project is not used in this case.
|
||||
*/
|
||||
def this() = this(ActorTestKit.create(TestKitUtils.testNameFromCallStack(classOf[TestKitJunitResource])))
|
||||
@noinline def this() = this(ActorTestKit.create(TestKitUtils.testNameFromCallStack(classOf[TestKitJunitResource])))
|
||||
|
||||
/**
|
||||
* Use a custom [[pekko.actor.typed.ActorSystem]] for the actor system.
|
||||
|
|
@ -76,7 +76,7 @@ final class TestKitJunitResource(_kit: ActorTestKit) extends ExternalResource {
|
|||
/**
|
||||
* Use a custom config for the actor system.
|
||||
*/
|
||||
def this(customConfig: String) =
|
||||
@noinline def this(customConfig: String) =
|
||||
this(
|
||||
ActorTestKit.create(
|
||||
TestKitUtils.testNameFromCallStack(classOf[TestKitJunitResource]),
|
||||
|
|
@ -85,13 +85,13 @@ final class TestKitJunitResource(_kit: ActorTestKit) extends ExternalResource {
|
|||
/**
|
||||
* Use a custom config for the actor system.
|
||||
*/
|
||||
def this(customConfig: Config) =
|
||||
@noinline def this(customConfig: Config) =
|
||||
this(ActorTestKit.create(TestKitUtils.testNameFromCallStack(classOf[TestKitJunitResource]), customConfig))
|
||||
|
||||
/**
|
||||
* Use a custom config for the actor system, and a custom [[pekko.actor.testkit.typed.TestKitSettings]].
|
||||
*/
|
||||
def this(customConfig: Config, settings: TestKitSettings) =
|
||||
@noinline def this(customConfig: Config, settings: TestKitSettings) =
|
||||
this(ActorTestKit.create(TestKitUtils.testNameFromCallStack(classOf[TestKitJunitResource]), customConfig, settings))
|
||||
|
||||
@Rule
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ object ActorTestKit {
|
|||
* using default configuration from the reference.conf resources that ship with the Akka libraries.
|
||||
* The application.conf of your project is not used in this case.
|
||||
*/
|
||||
def apply(): ActorTestKit = {
|
||||
@noinline def apply(): ActorTestKit = {
|
||||
val system = ActorSystem(
|
||||
ActorTestKitGuardian.testKitGuardian,
|
||||
TestKitUtils.testNameFromCallStack(classOf[ActorTestKit]),
|
||||
|
|
@ -111,7 +111,7 @@ object ActorTestKit {
|
|||
* When the test has completed you should terminate the `ActorSystem` and
|
||||
* the testkit with [[ActorTestKit#shutdownTestKit]].
|
||||
*/
|
||||
def apply(customConfig: Config): ActorTestKit = {
|
||||
@noinline def apply(customConfig: Config): ActorTestKit = {
|
||||
val system = ActorSystem(
|
||||
ActorTestKitGuardian.testKitGuardian,
|
||||
TestKitUtils.testNameFromCallStack(classOf[ActorTestKit]),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import pekko.actor.typed.Props
|
|||
import pekko.util.Timeout
|
||||
|
||||
object ActorTestKitBase {
|
||||
def testNameFromCallStack(): String = TestKitUtils.testNameFromCallStack(classOf[ActorTestKitBase])
|
||||
@noinline def testNameFromCallStack(): String = TestKitUtils.testNameFromCallStack(classOf[ActorTestKitBase])
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#CompletionStageOps.asScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#CompletionStageOps.asScala")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#CompletionStageOps.asScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#FutureOps.asJava$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#FutureOps.asJava")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#FutureOps.asJava$extension")
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJava$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJavaPrimitive$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJava")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJavaPrimitive")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJava$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJavaPrimitive$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toJavaPrimitive$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toScala")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toJavaPrimitive")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toJavaPrimitive$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toJavaGeneric$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toScala")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toJavaGeneric")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toJavaGeneric$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toJavaGeneric$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toScala")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toJavaGeneric")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toJavaGeneric$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toJavaGeneric$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toScala")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toJavaGeneric")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toScala$extension")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toJavaGeneric$extension")
|
||||
|
|
@ -38,11 +38,11 @@ object ByteIterator {
|
|||
extends ByteIterator {
|
||||
iterator =>
|
||||
|
||||
@inline final def len: Int = until - from
|
||||
final def len: Int = until - from
|
||||
|
||||
@inline final def hasNext: Boolean = from < until
|
||||
final def hasNext: Boolean = from < until
|
||||
|
||||
@inline final def head: Byte = array(from)
|
||||
final def head: Byte = array(from)
|
||||
|
||||
final def next(): Byte = {
|
||||
if (!hasNext) EmptyImmutableSeq.iterator.next()
|
||||
|
|
@ -206,13 +206,13 @@ object ByteIterator {
|
|||
}
|
||||
normalize()
|
||||
|
||||
@inline private def current: ByteArrayIterator = iterators.head
|
||||
@inline private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
@inline final def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
private def current: ByteArrayIterator = iterators.head
|
||||
private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
final def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
|
||||
@inline final def hasNext: Boolean = current.hasNext
|
||||
final def hasNext: Boolean = current.hasNext
|
||||
|
||||
@inline final def head: Byte = current.head
|
||||
final def head: Byte = current.head
|
||||
|
||||
final def next(): Byte = {
|
||||
val result = current.next()
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
this
|
||||
}
|
||||
|
||||
@inline protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
fillArray(len) {
|
||||
case (array, start) =>
|
||||
val buffer = ByteBuffer.wrap(array, start, len)
|
||||
|
|
@ -1078,7 +1078,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
_tempCapacity = _temp.length
|
||||
}
|
||||
|
||||
@inline private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
|
||||
private def ensureTempSize(size: Int): Unit = {
|
||||
if (shouldResizeTempFor(size)) {
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ object ByteIterator {
|
|||
extends ByteIterator {
|
||||
iterator =>
|
||||
|
||||
@inline final def len: Int = until - from
|
||||
final def len: Int = until - from
|
||||
|
||||
@inline final def hasNext: Boolean = from < until
|
||||
final def hasNext: Boolean = from < until
|
||||
|
||||
@inline final def head: Byte = array(from)
|
||||
final def head: Byte = array(from)
|
||||
|
||||
final def next(): Byte = {
|
||||
if (!hasNext) EmptyImmutableSeq.iterator.next()
|
||||
|
|
@ -218,13 +218,13 @@ object ByteIterator {
|
|||
}
|
||||
normalize()
|
||||
|
||||
@inline private def current: ByteArrayIterator = iterators.head
|
||||
@inline private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
@inline final def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
private def current: ByteArrayIterator = iterators.head
|
||||
private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
final def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
|
||||
@inline final def hasNext: Boolean = current.hasNext
|
||||
final def hasNext: Boolean = current.hasNext
|
||||
|
||||
@inline final def head: Byte = current.head
|
||||
final def head: Byte = current.head
|
||||
|
||||
final def next(): Byte = {
|
||||
val result = current.next()
|
||||
|
|
|
|||
|
|
@ -1097,7 +1097,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
this
|
||||
}
|
||||
|
||||
@inline protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
fillArray(len) {
|
||||
case (array, start) =>
|
||||
val buffer = ByteBuffer.wrap(array, start, len)
|
||||
|
|
@ -1128,7 +1128,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
_tempCapacity = _temp.length
|
||||
}
|
||||
|
||||
@inline private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
|
||||
private def ensureTempSize(size: Int): Unit = {
|
||||
if (shouldResizeTempFor(size)) {
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ object ByteIterator {
|
|||
extends ByteIterator {
|
||||
iterator =>
|
||||
|
||||
@inline final def len: Int = until - from
|
||||
final def len: Int = until - from
|
||||
|
||||
@inline final def hasNext: Boolean = from < until
|
||||
final def hasNext: Boolean = from < until
|
||||
|
||||
@inline final def head: Byte = array(from)
|
||||
final def head: Byte = array(from)
|
||||
|
||||
final def next(): Byte = {
|
||||
if (!hasNext) EmptyImmutableSeq.iterator.next()
|
||||
|
|
@ -215,13 +215,13 @@ object ByteIterator {
|
|||
}
|
||||
normalize()
|
||||
|
||||
@inline private def current: ByteArrayIterator = iterators.head
|
||||
@inline private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
@inline def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
private def current: ByteArrayIterator = iterators.head
|
||||
private def dropCurrent(): Unit = { iterators = iterators.tail }
|
||||
def clear(): Unit = { iterators = MultiByteArrayIterator.empty.iterators }
|
||||
|
||||
@inline final def hasNext: Boolean = current.hasNext
|
||||
final def hasNext: Boolean = current.hasNext
|
||||
|
||||
@inline final def head: Byte = current.head
|
||||
final def head: Byte = current.head
|
||||
|
||||
final def next(): Byte = {
|
||||
val result = current.next()
|
||||
|
|
|
|||
|
|
@ -1097,7 +1097,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
this
|
||||
}
|
||||
|
||||
@inline protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
protected final def fillByteBuffer(len: Int, byteOrder: ByteOrder)(fill: ByteBuffer => Unit): this.type = {
|
||||
fillArray(len) {
|
||||
case (array, start) =>
|
||||
val buffer = ByteBuffer.wrap(array, start, len)
|
||||
|
|
@ -1128,7 +1128,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
|
|||
_tempCapacity = _temp.length
|
||||
}
|
||||
|
||||
@inline private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
private def shouldResizeTempFor(size: Int): Boolean = _tempCapacity < size || _tempCapacity == 0
|
||||
|
||||
private def ensureTempSize(size: Int): Unit = {
|
||||
if (shouldResizeTempFor(size)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* license agreements; and to You under the Apache License, version 2.0:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* This file is part of the Apache Pekko project, derived from Akka.
|
||||
*/
|
||||
|
||||
package org.apache.pekko.util
|
||||
|
||||
import org.apache.pekko.annotation.InternalStableApi
|
||||
|
||||
import java.util.concurrent.CompletionStage
|
||||
import scala.concurrent.Future
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*
|
||||
* Remove this once Scala 2.12 support is dropped since all methods are in Scala 2.13+ stdlib
|
||||
*/
|
||||
@InternalStableApi
|
||||
private[pekko] object FutureConverters {
|
||||
import scala.jdk.javaapi
|
||||
|
||||
def asJava[T](f: Future[T]): CompletionStage[T] = javaapi.FutureConverters.asJava(f)
|
||||
|
||||
implicit final class FutureOps[T](private val f: Future[T]) extends AnyVal {
|
||||
inline def asJava: CompletionStage[T] = FutureConverters.asJava(f)
|
||||
}
|
||||
|
||||
def asScala[T](cs: CompletionStage[T]): Future[T] = javaapi.FutureConverters.asScala(cs)
|
||||
|
||||
implicit final class CompletionStageOps[T](private val cs: CompletionStage[T]) extends AnyVal {
|
||||
inline def asScala: Future[T] = FutureConverters.asScala(cs)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* license agreements; and to You under the Apache License, version 2.0:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* This file is part of the Apache Pekko project, derived from Akka.
|
||||
*/
|
||||
|
||||
package org.apache.pekko.util
|
||||
|
||||
import org.apache.pekko.annotation.InternalStableApi
|
||||
|
||||
import java.util._
|
||||
import scala.jdk.OptionShape
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*
|
||||
* Remove this once Scala 2.12 support is dropped since all methods are in Scala 2.13+ stdlib
|
||||
*/
|
||||
@InternalStableApi
|
||||
private[pekko] object OptionConverters {
|
||||
|
||||
inline final def toScala[A](o: Optional[A]): Option[A] = scala.jdk.javaapi.OptionConverters.toScala(o)
|
||||
|
||||
inline def toScala(o: OptionalDouble): Option[java.lang.Double] = scala.jdk.javaapi.OptionConverters.toScala(o)
|
||||
|
||||
inline def toScala(o: OptionalInt): Option[java.lang.Integer] = scala.jdk.javaapi.OptionConverters.toScala(o)
|
||||
|
||||
inline def toScala(o: OptionalLong): Option[java.lang.Long] = scala.jdk.javaapi.OptionConverters.toScala(o)
|
||||
|
||||
inline final def toJava[A](o: Option[A]): Optional[A] = scala.jdk.javaapi.OptionConverters.toJava(o)
|
||||
|
||||
implicit final class RichOptional[A](private val o: java.util.Optional[A]) extends AnyVal {
|
||||
inline def toScala: Option[A] = scala.jdk.OptionConverters.RichOptional(o).toScala
|
||||
|
||||
inline def toJavaPrimitive[O](implicit shape: OptionShape[A, O]): O =
|
||||
scala.jdk.OptionConverters.RichOptional(o).toJavaPrimitive
|
||||
}
|
||||
|
||||
implicit final class RichOption[A](private val o: Option[A]) extends AnyVal {
|
||||
inline def toJava: Optional[A] = scala.jdk.OptionConverters.RichOption(o).toJava
|
||||
|
||||
inline def toJavaPrimitive[O](implicit shape: OptionShape[A, O]): O =
|
||||
scala.jdk.OptionConverters.RichOption(o).toJavaPrimitive
|
||||
}
|
||||
|
||||
implicit class RichOptionalDouble(private val o: OptionalDouble) extends AnyVal {
|
||||
|
||||
/** Convert a Java `OptionalDouble` to a Scala `Option` */
|
||||
inline def toScala: Option[Double] = scala.jdk.OptionConverters.RichOptionalDouble(o).toScala
|
||||
|
||||
/** Convert a Java `OptionalDouble` to a generic Java `Optional` */
|
||||
inline def toJavaGeneric: Optional[Double] = scala.jdk.OptionConverters.RichOptionalDouble(o).toJavaGeneric
|
||||
}
|
||||
|
||||
/** Provides conversions from `OptionalInt` to Scala `Option` and the generic `Optional` */
|
||||
implicit class RichOptionalInt(private val o: OptionalInt) extends AnyVal {
|
||||
|
||||
/** Convert a Java `OptionalInt` to a Scala `Option` */
|
||||
inline def toScala: Option[Int] = scala.jdk.OptionConverters.RichOptionalInt(o).toScala
|
||||
|
||||
/** Convert a Java `OptionalInt` to a generic Java `Optional` */
|
||||
inline def toJavaGeneric: Optional[Int] = scala.jdk.OptionConverters.RichOptionalInt(o).toJavaGeneric
|
||||
}
|
||||
|
||||
/** Provides conversions from `OptionalLong` to Scala `Option` and the generic `Optional` */
|
||||
implicit class RichOptionalLong(private val o: OptionalLong) extends AnyVal {
|
||||
|
||||
/** Convert a Java `OptionalLong` to a Scala `Option` */
|
||||
inline def toScala: Option[Long] = scala.jdk.OptionConverters.RichOptionalLong(o).toScala
|
||||
|
||||
/** Convert a Java `OptionalLong` to a generic Java `Optional` */
|
||||
inline def toJavaGeneric: Optional[Long] = scala.jdk.OptionConverters.RichOptionalLong(o).toJavaGeneric
|
||||
}
|
||||
}
|
||||
|
|
@ -860,7 +860,6 @@ private[pekko] class ActorSystemImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@inline
|
||||
private def logFatalError(message: String, cause: Throwable, thread: Thread): Unit = {
|
||||
// First log to stderr as this has the best chance to get through in an 'emergency panic' situation:
|
||||
import System.err
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ private[pekko] trait Children { this: ActorCell =>
|
|||
/*
|
||||
* low level CAS helpers
|
||||
*/
|
||||
@inline private final def swapChildrenRefs(oldChildren: ChildrenContainer, newChildren: ChildrenContainer): Boolean =
|
||||
private final def swapChildrenRefs(oldChildren: ChildrenContainer, newChildren: ChildrenContainer): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(this, AbstractActorCell.childrenOffset, oldChildren, newChildren)
|
||||
|
||||
@tailrec final def reserveChild(name: String): Boolean = {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ private[pekko] trait Dispatch { this: ActorCell =>
|
|||
_mailboxDoNotCallMeDirectly
|
||||
}
|
||||
|
||||
@inline final def mailbox: Mailbox =
|
||||
final def mailbox: Mailbox =
|
||||
Unsafe.instance.getObjectVolatile(this, AbstractActorCell.mailboxOffset).asInstanceOf[Mailbox]
|
||||
|
||||
@tailrec final def swapMailbox(newMailbox: Mailbox): Mailbox = {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import language.implicitConversions
|
|||
|
||||
package object actor {
|
||||
@deprecated("implicit conversion is obsolete", "Akka 2.6.13")
|
||||
@inline implicit final def actorRef2Scala(ref: ActorRef): ScalaActorRef = ref.asInstanceOf[ScalaActorRef]
|
||||
implicit final def actorRef2Scala(ref: ActorRef): ScalaActorRef = ref.asInstanceOf[ScalaActorRef]
|
||||
@deprecated("implicit conversion is obsolete", "Akka 2.6.13")
|
||||
@inline implicit final def scala2ActorRef(ref: ScalaActorRef): ActorRef = ref.asInstanceOf[ActorRef]
|
||||
implicit final def scala2ActorRef(ref: ScalaActorRef): ActorRef = ref.asInstanceOf[ActorRef]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ abstract class MessageDispatcher(val configurator: MessageDispatcherConfigurator
|
|||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@inline protected[pekko] final val isThroughputDeadlineTimeDefined = throughputDeadlineTime.toMillis > 0
|
||||
protected[pekko] final val isThroughputDeadlineTimeDefined = throughputDeadlineTime.toMillis > 0
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
|
|
|
|||
|
|
@ -121,29 +121,21 @@ private[pekko] abstract class Mailbox(val messageQueue: MessageQueue)
|
|||
@volatile
|
||||
protected var _systemQueueDoNotCallMeDirectly: SystemMessage = _ // null by default
|
||||
|
||||
@inline
|
||||
final def currentStatus: Mailbox.Status = Unsafe.instance.getIntVolatile(this, AbstractMailbox.mailboxStatusOffset)
|
||||
|
||||
@inline
|
||||
final def shouldProcessMessage: Boolean = (currentStatus & shouldNotProcessMask) == 0
|
||||
|
||||
@inline
|
||||
final def suspendCount: Int = currentStatus / suspendUnit
|
||||
|
||||
@inline
|
||||
final def isSuspended: Boolean = (currentStatus & suspendMask) != 0
|
||||
|
||||
@inline
|
||||
final def isClosed: Boolean = currentStatus == Closed
|
||||
|
||||
@inline
|
||||
final def isScheduled: Boolean = (currentStatus & Scheduled) != 0
|
||||
|
||||
@inline
|
||||
protected final def updateStatus(oldStatus: Status, newStatus: Status): Boolean =
|
||||
Unsafe.instance.compareAndSwapInt(this, AbstractMailbox.mailboxStatusOffset, oldStatus, newStatus)
|
||||
|
||||
@inline
|
||||
protected final def setStatus(newStatus: Status): Unit =
|
||||
Unsafe.instance.putIntVolatile(this, AbstractMailbox.mailboxStatusOffset, newStatus)
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ private[affinity] object AffinityPool {
|
|||
private[this] var parkPeriodNs = 0L
|
||||
@volatile private[this] var idling = false
|
||||
|
||||
@inline private[this] def transitionTo(newState: IdleState): Unit = {
|
||||
private[this] def transitionTo(newState: IdleState): Unit = {
|
||||
state = newState
|
||||
turns = 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -485,10 +485,10 @@ object Logging {
|
|||
* Marker trait for annotating LogLevel, which must be Int after erasure.
|
||||
*/
|
||||
final case class LogLevel(asInt: Int) extends AnyVal {
|
||||
@inline final def >=(other: LogLevel): Boolean = asInt >= other.asInt
|
||||
@inline final def <=(other: LogLevel): Boolean = asInt <= other.asInt
|
||||
@inline final def >(other: LogLevel): Boolean = asInt > other.asInt
|
||||
@inline final def <(other: LogLevel): Boolean = asInt < other.asInt
|
||||
final def >=(other: LogLevel): Boolean = asInt >= other.asInt
|
||||
final def <=(other: LogLevel): Boolean = asInt <= other.asInt
|
||||
final def >(other: LogLevel): Boolean = asInt > other.asInt
|
||||
final def <(other: LogLevel): Boolean = asInt < other.asInt
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -549,11 +549,9 @@ private[pekko] final class PromiseActorRef(
|
|||
_watchedByDoNotCallMeDirectly
|
||||
}
|
||||
|
||||
@inline
|
||||
private[this] def watchedBy: Set[ActorRef] =
|
||||
Unsafe.instance.getObjectVolatile(this, watchedByOffset).asInstanceOf[Set[ActorRef]]
|
||||
|
||||
@inline
|
||||
private[this] def updateWatchedBy(oldWatchedBy: Set[ActorRef], newWatchedBy: Set[ActorRef]): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(this, watchedByOffset, oldWatchedBy, newWatchedBy)
|
||||
|
||||
|
|
@ -575,14 +573,11 @@ private[pekko] final class PromiseActorRef(
|
|||
case other => if (!updateWatchedBy(other, null)) clearWatchers() else other
|
||||
}
|
||||
|
||||
@inline
|
||||
private[this] def state: AnyRef = Unsafe.instance.getObjectVolatile(this, stateOffset)
|
||||
|
||||
@inline
|
||||
private[this] def updateState(oldState: AnyRef, newState: AnyRef): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(this, stateOffset, oldState, newState)
|
||||
|
||||
@inline
|
||||
private[this] def setState(newState: AnyRef): Unit = Unsafe.instance.putObjectVolatile(this, stateOffset, newState)
|
||||
|
||||
override def getParent: InternalActorRef = provider.tempContainer
|
||||
|
|
|
|||
|
|
@ -317,7 +317,6 @@ class CircuitBreaker(
|
|||
* @param newState Next state on transition
|
||||
* @return Whether the previous state matched correctly
|
||||
*/
|
||||
@inline
|
||||
private[this] def swapState(oldState: State, newState: State): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(this, AbstractCircuitBreaker.stateOffset, oldState, newState)
|
||||
|
||||
|
|
@ -326,14 +325,12 @@ class CircuitBreaker(
|
|||
*
|
||||
* @return Reference to current state
|
||||
*/
|
||||
@inline
|
||||
private[this] def currentState: State =
|
||||
Unsafe.instance.getObjectVolatile(this, AbstractCircuitBreaker.stateOffset).asInstanceOf[State]
|
||||
|
||||
/**
|
||||
* Helper method for updating the underlying resetTimeout via Unsafe
|
||||
*/
|
||||
@inline
|
||||
private[this] def swapResetTimeout(oldResetTimeout: FiniteDuration, newResetTimeout: FiniteDuration): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(
|
||||
this,
|
||||
|
|
@ -344,7 +341,6 @@ class CircuitBreaker(
|
|||
/**
|
||||
* Helper method for accessing to the underlying resetTimeout via Unsafe
|
||||
*/
|
||||
@inline
|
||||
private[this] def currentResetTimeout: FiniteDuration =
|
||||
Unsafe.instance.getObjectVolatile(this, AbstractCircuitBreaker.resetTimeoutOffset).asInstanceOf[FiniteDuration]
|
||||
|
||||
|
|
|
|||
|
|
@ -286,13 +286,13 @@ case object FromConfig extends FromConfig {
|
|||
* Java API: get the singleton instance
|
||||
*/
|
||||
def getInstance = this
|
||||
@inline final def apply(
|
||||
final def apply(
|
||||
resizer: Option[Resizer] = None,
|
||||
supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
|
||||
routerDispatcher: String = Dispatchers.DefaultDispatcherId) =
|
||||
new FromConfig(resizer, supervisorStrategy, routerDispatcher)
|
||||
|
||||
@inline final def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher)
|
||||
final def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ object Helpers {
|
|||
*
|
||||
* @param value The value to check.
|
||||
*/
|
||||
@inline final implicit class Requiring[A](val value: A) extends AnyVal {
|
||||
final implicit class Requiring[A](val value: A) extends AnyVal {
|
||||
|
||||
/**
|
||||
* Check that a condition is true. If true, return `value`, otherwise throw
|
||||
|
|
@ -149,7 +149,7 @@ object Helpers {
|
|||
* @param cond The condition to check.
|
||||
* @param msg The message to report if the condition isn't met.
|
||||
*/
|
||||
@inline def requiring(cond: Boolean, msg: => Any): A = {
|
||||
def requiring(cond: Boolean, msg: => Any): A = {
|
||||
require(cond, msg)
|
||||
value
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ object Helpers {
|
|||
* @param cond The function used to check the `value`.
|
||||
* @param msg The message to report if the condition isn't met.
|
||||
*/
|
||||
@inline def requiring(cond: A => Boolean, msg: => Any): A = {
|
||||
def requiring(cond: A => Boolean, msg: => Any): A = {
|
||||
require(cond(value), msg)
|
||||
value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import java.util.concurrent.locks.ReentrantLock
|
|||
|
||||
final class ReentrantGuard extends ReentrantLock {
|
||||
|
||||
@inline
|
||||
final def withGuard[T](body: => T): T = {
|
||||
lock()
|
||||
try body
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ trait SnapshotStore extends Actor with ActorLogging {
|
|||
}
|
||||
|
||||
/** Documents intent that the sender() is expected to be the PersistentActor */
|
||||
@inline private final def senderPersistentActor(): ActorRef = sender()
|
||||
private final def senderPersistentActor(): ActorRef = sender()
|
||||
|
||||
private def tryReceivePluginInternal(evt: Any): Unit =
|
||||
if (receivePluginInternal.isDefinedAt(evt)) receivePluginInternal(evt)
|
||||
|
|
|
|||
47
project/PekkoInlinePlugin.scala
Normal file
47
project/PekkoInlinePlugin.scala
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* license agreements; and to You under the Apache License, version 2.0:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* This file is part of the Apache Pekko project, derived from Akka.
|
||||
*/
|
||||
|
||||
import sbt.Keys._
|
||||
import sbt._
|
||||
import sbt.plugins.JvmPlugin
|
||||
|
||||
object PekkoInlinePlugin extends AutoPlugin {
|
||||
override def trigger: PluginTrigger = allRequirements
|
||||
|
||||
override def requires: Plugins = JvmPlugin
|
||||
|
||||
val enabled = !sys.props.contains("pekko.no.inline")
|
||||
|
||||
private val flagsFor212 = Seq(
|
||||
"-opt-inline-from:org.apache.pekko.**",
|
||||
"-opt-inline-from:<sources>",
|
||||
"-opt:l:inline")
|
||||
|
||||
private val flagsFor213 = Seq(
|
||||
"-opt-inline-from:org.apache.pekko.**",
|
||||
"-opt-inline-from:<sources>",
|
||||
"-opt:l:inline")
|
||||
|
||||
// Optimizer not yet available for Scala3, see https://docs.scala-lang.org/overviews/compiler-options/optimizer.html
|
||||
private val flagsFor3 = Seq()
|
||||
|
||||
override lazy val projectSettings = Seq(
|
||||
Compile / scalacOptions ++= {
|
||||
if (enabled) {
|
||||
CrossVersion.partialVersion(scalaVersion.value) match {
|
||||
case Some((2, n)) if n == 13 =>
|
||||
flagsFor213
|
||||
case Some((2, n)) if n == 12 =>
|
||||
flagsFor212
|
||||
case Some((3, _)) =>
|
||||
flagsFor3
|
||||
}
|
||||
} else Seq.empty
|
||||
})
|
||||
}
|
||||
|
|
@ -270,7 +270,6 @@ private[remote] class Association(
|
|||
* @param newState Next state on transition
|
||||
* @return Whether the previous state matched correctly
|
||||
*/
|
||||
@inline
|
||||
private[artery] def swapState(oldState: AssociationState, newState: AssociationState): Boolean =
|
||||
Unsafe.instance.compareAndSwapObject(this, AbstractAssociation.sharedStateOffset, oldState, newState)
|
||||
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ private[remote] final class TopHeavyHitters[T >: Null](val max: Int)(implicit cl
|
|||
v
|
||||
}
|
||||
|
||||
@inline private final def index: Int = heap(i)
|
||||
@inline private final def value: T = {
|
||||
private final def index: Int = heap(i)
|
||||
private final def value: T = {
|
||||
val idx = index
|
||||
if (idx < 0) null else items(idx)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ class Slf4jLogger extends Actor with SLF4JLogging with RequiresMessageQueue[Logg
|
|||
sender() ! LoggerInitialized
|
||||
}
|
||||
|
||||
@inline
|
||||
final def withMdc(logSource: String, logEvent: LogEvent)(logStatement: => Unit): Unit = {
|
||||
logEvent match {
|
||||
case m: LogEventWithMarker if m.marker ne null =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue