From: David ‘Bombe’ Roden Date: Thu, 12 Dec 2019 19:02:56 +0000 (+0100) Subject: 🚧 Change rescheduling method X-Git-Tag: v81^2~5^2~32 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=439fb3dfa1ccf157388a0e0b306013d0aa46bb50;p=Sone.git 🚧 Change rescheduling method --- diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt index 9d0522d..026389f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt @@ -22,6 +22,7 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.freenet.plugin.* import net.pterodactylus.sone.utils.* import java.util.concurrent.atomic.* +import java.util.function.* import javax.inject.* /** @@ -32,7 +33,7 @@ import javax.inject.* class WebOfTrustPinger @Inject constructor( private val eventBus: EventBus, @Named("webOfTrustReacher") private val webOfTrustReacher: Runnable, - @Named("webOfTrustReschedule") private val reschedule: Runnable) : Runnable { + @Named("webOfTrustReschedule") private val reschedule: Consumer) : Runnable { private val lastState = AtomicBoolean(false) @@ -49,7 +50,7 @@ class WebOfTrustPinger @Inject constructor( lastState.set(false) } } - reschedule() + reschedule(this) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt index 9743449..cbd9172 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt @@ -24,6 +24,7 @@ import net.pterodactylus.sone.utils.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import java.util.concurrent.atomic.* +import java.util.function.* import kotlin.test.* /** @@ -35,7 +36,7 @@ class WebOfTrustPingerTest { private val webOfTrustReachable = AtomicBoolean() private val webOfTrustReacher = Runnable { webOfTrustReachable.get().onFalse { throw PluginException() } } private val rescheduled = AtomicBoolean() - private val reschedule = Runnable { rescheduled.set(true) } + private val reschedule: Consumer = Consumer { if (it == pinger) rescheduled.set(true) } private val pinger = WebOfTrustPinger(eventBus, webOfTrustReacher, reschedule) @Test