import net.pterodactylus.sone.freenet.plugin.*
import net.pterodactylus.sone.utils.*
import java.util.concurrent.atomic.*
+import java.util.function.*
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>) : Runnable {
private val lastState = AtomicBoolean(false)
lastState.set(false)
}
}
- reschedule()
+ reschedule(this)
}
}
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import java.util.concurrent.atomic.*
+import java.util.function.*
import kotlin.test.*
/**
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<Runnable> = Consumer { if (it == pinger) rescheduled.set(true) }
private val pinger = WebOfTrustPinger(eventBus, webOfTrustReacher, reschedule)
@Test