X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FWebOfTrustPinger.kt;h=db9809efd387703620ec6d83dca15eb43ee83638;hp=e090133d385648324cc42da0cda8a702535b257b;hb=438378deab1514f0f608d975ef65f5b7aea44ccb;hpb=ceac45f8b8a241e8f9809d70eeda7897f5e280b7 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 e090133..db9809e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt @@ -1,5 +1,5 @@ /** - * Sone - WebOfTrustPinger.kt - Copyright © 2019 David ‘Bombe’ Roden + * Sone - WebOfTrustPinger.kt - Copyright © 2019–2020 David ‘Bombe’ Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,14 +20,20 @@ package net.pterodactylus.sone.freenet.wot import com.google.common.eventbus.* 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.* /** * [Runnable] that is scheduled via an [Executor][java.util.concurrent.Executor], * checks whether the web of trust plugin can be communicated with, sends * events if its status changes and reschedules itself. */ -class WebOfTrustPinger(private val eventBus: EventBus, private val webOfTrustReacher: () -> Unit, private val reschedule: () -> Unit) : Runnable { +class WebOfTrustPinger @Inject constructor( + private val eventBus: EventBus, + @Named("webOfTrustReacher") private val webOfTrustReacher: Runnable, + @Named("webOfTrustReschedule") private val reschedule: Consumer) : Runnable { private val lastState = AtomicBoolean(false) @@ -44,7 +50,7 @@ class WebOfTrustPinger(private val eventBus: EventBus, private val webOfTrustRea lastState.set(false) } } - reschedule() + reschedule(this) } }