1 | | | import 'package:meta/meta.dart'; |
2 | | |
|
3 | | | import '../_impl/xplat/_time_stamp.dart'; |
4 | | |
|
5 | | | /// Make [WorkerMessage] a `List` to minimize serialization overhead. |
6 | | | extension type WorkerMessage(List data) { |
7 | | | /// [travelTime] is set by the receiving end and measures the time (in |
8 | | | /// microseconds) it took between the moment the message was serialized and |
9 | | | /// the moment it was deserialized. |
10 | | 0 | int? get travelTime => data[_$traveltime]; |
11 | | | } |
12 | | |
|
13 | | | const _$traveltime = 0; |
14 | | |
|
15 | | | @internal |
16 | | | extension WorkerMessageExt on WorkerMessage { |
17 | | 10 | void unwrapTravelTime() { |
18 | | 30 | final ts = (data[_$traveltime] as num?)?.toInt(); |
19 | | 12 | if (ts != null) { |
20 | | 39 | data[_$traveltime] = microsecTimeStamp() - ts; |
21 | | | } |
22 | | 1 | } |
23 | | | } |