finish switch to event sequence

This commit is contained in:
Fabian Freund
2026-02-10 16:53:16 +01:00
parent 188dfdd003
commit 83673227f3
4 changed files with 33 additions and 12 deletions
@@ -22,7 +22,7 @@ package eu.weblibre.simple_intent_receiver
import io.flutter.plugin.common.BinaryMessenger
import eu.weblibre.simple_intent_receiver.pigeons.IntentEvents
import eu.weblibre.simple_intent_receiver.pigeons.Intent as PigeonIntent
import eu.weblibre.flutter_mozilla_components.ext.EventSequence
import eu.weblibre.simple_intent_receiver.ext.EventSequence
class IntentReceiver(messenger: BinaryMessenger) {
private val intentEvents: IntentEvents = IntentEvents(messenger)
@@ -31,4 +31,3 @@ class IntentReceiver(messenger: BinaryMessenger) {
intentEvents.onIntentReceived(EventSequence.next(), intent) { }
}
}
}
@@ -0,0 +1,22 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package eu.weblibre.simple_intent_receiver.ext
import java.util.concurrent.atomic.AtomicLong
/**
* Thread-safe monotonic sequence counter for event ordering.
*
* Replaces System.currentTimeMillis() for event timestamps sent to Flutter,
* guaranteeing strictly increasing values regardless of wall-clock changes
* and eliminating same-millisecond collisions.
*/
object EventSequence {
private val counter = AtomicLong(0)
fun next(): Long = counter.incrementAndGet()
}