fix: Proces threading fix
This commit is contained in:
parent
116b13adcb
commit
75e10c1579
3 changed files with 20 additions and 16 deletions
|
@ -23,7 +23,7 @@ class Garmin(
|
|||
) {
|
||||
|
||||
private lateinit var connection: ConnectThread
|
||||
private lateinit var processing: ProcessingThread
|
||||
private val observer = ProcessingThreadObserver()
|
||||
private val cache = DataCache()
|
||||
|
||||
fun start() {
|
||||
|
@ -36,15 +36,11 @@ class Garmin(
|
|||
}
|
||||
|
||||
fun process(maneuver: Maneuver) {
|
||||
processing = ManeuverProcessingThread(maneuver)
|
||||
processing.start()
|
||||
processing.join()
|
||||
ManeuverProcessingThread(maneuver).start()
|
||||
}
|
||||
|
||||
fun process(location: LocationMatcherResult) {
|
||||
processing = LocationProcessingThread(location)
|
||||
processing.start()
|
||||
processing.join()
|
||||
LocationProcessingThread(location).start()
|
||||
}
|
||||
|
||||
fun process(navigationSessionState: NavigationSessionState) {
|
||||
|
@ -83,6 +79,15 @@ class Garmin(
|
|||
connection.enqueue(GarminMapper.setDirection(incoming))
|
||||
}
|
||||
cache.update(incoming)
|
||||
observer.join(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private inner class ProcessingThreadObserver {
|
||||
|
||||
fun join(thread: ProcessingThread) {
|
||||
thread.join()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -165,6 +170,8 @@ class Garmin(
|
|||
|
||||
companion object {
|
||||
|
||||
lateinit var instance: Garmin
|
||||
|
||||
fun prepareData(input: IntArray): IntArray {
|
||||
val n = input.size
|
||||
var crc = (0xeb + n + n).toUInt()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue