diff --git a/.sbt-java-formatter.conf b/.sbt-java-formatter.conf index 22dbb93843..c194cf733a 100644 --- a/.sbt-java-formatter.conf +++ b/.sbt-java-formatter.conf @@ -13,7 +13,6 @@ ignored-files = [ "FlightAppModels.java", //pekko-actor - "OnSpinWait.java", "AbstractBoundedNodeQueue.java", "AbstractMessageDispatcher.java", "AbstractNodeQueue.java", diff --git a/actor/src/main/java/org/apache/pekko/dispatch/affinity/OnSpinWait.java b/actor/src/main/java/org/apache/pekko/dispatch/affinity/OnSpinWait.java deleted file mode 100644 index a1a6497dff..0000000000 --- a/actor/src/main/java/org/apache/pekko/dispatch/affinity/OnSpinWait.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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, which was derived from Akka. - */ - -/* - * Copyright (C) 2009-2022 Lightbend Inc. - */ - -package org.apache.pekko.dispatch.affinity; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import org.apache.pekko.annotation.InternalApi; -import static java.lang.invoke.MethodType.methodType; - -/** - * INTERNAL API - */ -@InternalApi -final class OnSpinWait { - private final static MethodHandle handle; - - public final static void spinWait() throws Throwable { - handle.invoke(); // Will be inlined as an invokeExact since the callsite matches the MH definition of () -> void - } - - static { - final MethodHandle noop = MethodHandles.constant(Object.class, null).asType(methodType(Void.TYPE)); - MethodHandle impl; - try { - impl = MethodHandles.lookup().findStatic(Thread.class, "onSpinWait", methodType(Void.TYPE)); - } catch (NoSuchMethodException nsme) { - impl = noop; - } catch (IllegalAccessException iae) { - impl = noop; - } - handle = impl; - }; -} \ No newline at end of file diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/affinity/AffinityPool.scala b/actor/src/main/scala/org/apache/pekko/dispatch/affinity/AffinityPool.scala index a1be4c479f..c34d39bc9d 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/affinity/AffinityPool.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/affinity/AffinityPool.scala @@ -85,7 +85,7 @@ private[affinity] object AffinityPool { idling = true transitionTo(Spinning) case Spinning => - OnSpinWait.spinWait() + Thread.onSpinWait() turns += 1 if (turns > maxSpins) transitionTo(Yielding)