Added cloneToNormal, which converts the coroutine strategy -> thread strategy

This commit is contained in:
Robinson 2021-04-29 10:02:59 +02:00
parent 1e077c2d98
commit 47b63173ac
4 changed files with 26 additions and 4 deletions

View File

@ -621,10 +621,10 @@ open class Client<CONNECTION : Connection>(config: Configuration = Configuration
* Removes the specified host address from the list of registered server keys.
*/
fun removeRegisteredServerKey(address: InetAddress) {
val savedPublicKey = settingsStore.getRegisteredServerKey(address)
val savedPublicKey = storage.getRegisteredServerKey(address)
if (savedPublicKey != null) {
logger.debug { "Deleting remote IP address key $address" }
settingsStore.removeRegisteredServerKey(address)
storage.removeRegisteredServerKey(address)
}
}

View File

@ -17,6 +17,7 @@ package dorkbox.network.aeron
import kotlinx.coroutines.delay
import kotlinx.coroutines.yield
import org.agrona.concurrent.BackoffIdleStrategy
import org.agrona.hints.ThreadHints
abstract class BackoffIdleStrategyPrePad {
@ -214,8 +215,7 @@ class CoroutineBackoffIdleStrategy : BackoffIdleStrategyData, CoroutineIdleStrat
* @param minParkPeriodMs to use when initiating parking
* @param maxParkPeriodMs to use for end duration when parking
*/
constructor(
maxSpins: Long, maxYields: Long, minParkPeriodMs: Long, maxParkPeriodMs: Long)
constructor(maxSpins: Long, maxYields: Long, minParkPeriodMs: Long, maxParkPeriodMs: Long)
: super(maxSpins, maxYields, minParkPeriodMs, maxParkPeriodMs) {
}
@ -333,6 +333,13 @@ class CoroutineBackoffIdleStrategy : BackoffIdleStrategyData, CoroutineIdleStrat
return CoroutineBackoffIdleStrategy(maxSpins = maxSpins, maxYields = maxYields, minParkPeriodMs = minParkPeriodMs, maxParkPeriodMs = maxParkPeriodMs)
}
/**
* Creates a clone of this IdleStrategy
*/
override fun cloneToNormal(): BackoffIdleStrategy {
return BackoffIdleStrategy(maxSpins, maxYields, minParkPeriodMs, maxParkPeriodMs)
}
override fun toString(): String {
return "BackoffIdleStrategy{" +
"alias=" + ALIAS +

View File

@ -15,6 +15,8 @@
*/
package dorkbox.network.aeron
import org.agrona.concurrent.IdleStrategy
/**
* Idle strategy for use by threads when they do not have work to do.
*
@ -107,4 +109,9 @@ interface CoroutineIdleStrategy {
* Creates a clone of this IdleStrategy
*/
fun clone(): CoroutineIdleStrategy
/**
* Creates a clone of this IdleStrategy
*/
fun cloneToNormal(): IdleStrategy
}

View File

@ -16,6 +16,7 @@
package dorkbox.network.aeron
import kotlinx.coroutines.delay
import org.agrona.concurrent.SleepingMillisIdleStrategy
/**
* When idle this strategy is to sleep for a specified period time in milliseconds.
@ -90,6 +91,13 @@ class CoroutineSleepingMillisIdleStrategy : CoroutineIdleStrategy {
return CoroutineSleepingMillisIdleStrategy(sleepPeriodMs = sleepPeriodMs)
}
/**
* Creates a clone of this IdleStrategy
*/
override fun cloneToNormal(): SleepingMillisIdleStrategy {
return SleepingMillisIdleStrategy(sleepPeriodMs)
}
override fun toString(): String {
return "SleepingMillisIdleStrategy{" +