jimn
03/05/2020, 9:13 AMprivate fun scheduleTask(address: MemberAddress, command: Runnable, delay: Int, units: TimeUnit) {
waiting.computeIfAbsent(address) { a: MemberAddress? ->
lateinit var future: ScheduledFuture<*>
executor.schedule(loggingExceptions(Runnable {
waiting.remove(address, future )
command.run()
}), delay.toLong(), TimeUnit.MILLISECONDS) .also { future=it }
}
}
diesieben07
03/05/2020, 9:22 AMdiesieben07
03/05/2020, 9:23 AMvar x: String = "hello"
val runnable = Runnable {
x += " world"
}
jimn
03/05/2020, 9:24 AM.also{future=it}
appears to be doing the array of one hack, which seems like I'm forgetting a cleaner trick