Migrate from deprecated APIs

This commit is contained in:
Mygod
2021-05-05 10:04:55 -04:00
parent 71bfeb059b
commit 5c4f88967b
6 changed files with 23 additions and 28 deletions

View File

@@ -8,7 +8,8 @@ import java.nio.ByteOrder
/**
* Compat support class for [MacAddress].
*/
inline class MacAddressCompat(val addr: Long) {
@JvmInline
value class MacAddressCompat(val addr: Long) {
companion object {
private const val ETHER_ADDR_LEN = 6
/**

View File

@@ -5,9 +5,7 @@ import be.mygod.vpnhotspot.net.IpNeighbour
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.*
class IpNeighbourMonitor private constructor() : IpMonitor() {
companion object {
@@ -69,7 +67,7 @@ class IpNeighbourMonitor private constructor() : IpMonitor() {
IpNeighbour.State.DELETING -> neighbours.remove(IpDev(neighbour))
else -> neighbours.put(IpDev(neighbour), neighbour)
}
if (neighbours != old) aggregator.sendBlocking(neighbours)
if (neighbours != old) aggregator.trySendBlocking(neighbours).onFailure { throw it!! }
}
override fun processLines(lines: Sequence<String>) {
@@ -78,6 +76,6 @@ class IpNeighbourMonitor private constructor() : IpMonitor() {
.filter { it.state != IpNeighbour.State.DELETING } // skip entries without lladdr
.associateByTo(persistentMapOf<IpDev, IpNeighbour>().builder()) { IpDev(it) }
.build()
aggregator.sendBlocking(neighbours)
aggregator.trySendBlocking(neighbours).onFailure { throw it!! }
}
}