ensure random positive Int
parent
bcaa96ab30
commit
af1b75ce7d
|
@ -12,6 +12,7 @@ object ThreadLocalRandom {
|
|||
def nextFloat(): Float = current.nextFloat()
|
||||
def nextInt(): Int = current.nextInt()
|
||||
def nextInt(n: Int): Int = current.nextInt(n)
|
||||
def nextPositiveInt(): Int = current.nextInt(Int.MaxValue)
|
||||
def nextLong(): Long = current.nextLong()
|
||||
def nextChar(): Char = {
|
||||
val i = nextInt(62)
|
||||
|
|
|
@ -38,7 +38,7 @@ final class RemoteSocket(
|
|||
private val requests = new ConcurrentHashMap[Int, Promise[String]](32)
|
||||
|
||||
def request[R](sendReq: Int => Unit, readRes: String => R): Fu[R] = {
|
||||
val id = Math.abs(lila.common.ThreadLocalRandom.nextInt())
|
||||
val id = lila.common.ThreadLocalRandom.nextPositiveInt()
|
||||
sendReq(id)
|
||||
val promise = Promise[String]()
|
||||
requests.put(id, promise)
|
||||
|
|
Loading…
Reference in New Issue