You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by fa...@apache.org on 2023/06/15 10:33:22 UTC

[incubator-pekko] branch main updated: remove sequence id generator (#399)

This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 6bdce7f95b remove sequence id generator (#399)
6bdce7f95b is described below

commit 6bdce7f95bf09b666342ab80807b9ccb5f3aed77
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Thu Jun 15 11:33:16 2023 +0100

    remove sequence id generator (#399)
---
 .../scala/org/apache/pekko/io/dns/IdGenerator.scala | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala b/actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala
index 5bb3191f14..59c9e18c5a 100644
--- a/actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala
+++ b/actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala
@@ -13,8 +13,6 @@ import org.apache.pekko.annotation.InternalApi
 
 import java.security.SecureRandom
 import java.util.concurrent.ThreadLocalRandom
-import java.util.concurrent.atomic.AtomicInteger
-import scala.annotation.tailrec
 
 /**
  * INTERNAL API
@@ -59,23 +57,4 @@ private[pekko] object IdGenerator {
   def random(rand: java.util.Random): IdGenerator = new IdGenerator {
     override def nextId(): Short = rand.nextInt(Short.MaxValue).toShort
   }
-
-  /**
-   * @return a predictable sequence of ids for tests
-   */
-  def sequence(): IdGenerator = new IdGenerator {
-    val requestId: AtomicInteger = new AtomicInteger(0)
-
-    @tailrec
-    override final def nextId(): Short = {
-      val oldId = requestId.get()
-      val newId = (oldId + 1) % Short.MaxValue
-
-      if (requestId.compareAndSet(oldId, newId.intValue())) {
-        newId.toShort
-      } else {
-        nextId()
-      }
-    }
-  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org