Commit f05e1a1
committed
Use Duration as the ground truth for communicating durations
Historically, the library evolved using "a Long of milliseconds"
as the standard of denoting durations.
Since then, `kotlin.time.Duration` appeared, encompassing a number
of useful conversions.
There are several consequences to this change.
- Before, `delay(Long)` and `delay(Duration)` were not easily
expressed via one another.
For example, `delay(Long.MAX_VALUE / 2 + 1)`
(up until `Long.MAX_VALUE`) used to be considered a valid
delay, but it was not expressible in `delay(Duration)`.
Therefore, `delay(Long)` was the more fundamental implementation.
However, `delay(Duration)` could not just be expressed as
`delay(inWholeMilliseconds)`, as we need to round the durations
up when delaying events, and this required complex logic.
With this change, `delay(Duration)` is taken as the standard
implementation, and `delay(Long)` is just
`delay(timeMillis.milliseconds)`, simplifying the conceptual
space.
- The same goes for other APIs accepting either a duration or
some Long number of milliseconds.
- In several platform APIs, we are actually able to
pass nanoseconds as the duration to wait for.
We can now accurately do that. This precision is unlikely to
be important in practice, but it is still nice that we are
not losing any information in transit.
- On Android's main thread, it's no longer possible to wait for
`Long.MAX_VALUE / 2` milliseconds: it's considered an infinite
duration.
`Long.MAX_VALUE / 2 - 1` is still fine.
- In `kotlinx-coroutines-test`, before, it was possible to
observe correct behavior for up to `Long.MAX_VALUE` milliseconds.
Now, this value is drastically reduced, to be able to test
the nanosecond precision.
- In `kotlinx-coroutines-test`, we now fail with
an `IllegalStateException` if we enter the
representable ceiling of time during the test.
Before, we used to continue the test execution, only using the
order in which tasks arrived but not their virtual time values.1 parent 96de301 commit f05e1a1
56 files changed
Lines changed: 461 additions & 450 deletions
File tree
- docs/topics
- kotlinx-coroutines-core
- api
- common
- src
- flow
- operators
- selects
- test
- flow
- sharing
- jvm
- src
- channels
- internal
- time
- test-resources/stacktraces/timeout
- test
- examples/test
- flow
- guide/test
- scheduling
- nativeDarwin/src
- native/src
- wasmWasi/src
- kotlinx-coroutines-test
- api
- common/src
- internal
- jvm
- src/migration
- test/migration
- reactive
- kotlinx-coroutines-reactor
- api
- src
- kotlinx-coroutines-rx2
- api
- src
- kotlinx-coroutines-rx3
- api
- src
- ui
- kotlinx-coroutines-android
- android-unit-tests/test/ordered/tests
- api
- src
- test
- kotlinx-coroutines-javafx
- api
- src
- kotlinx-coroutines-swing
- api
- src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
| 325 | + | |
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
307 | | - | |
| 306 | + | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
297 | | - | |
298 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| 761 | + | |
761 | 762 | | |
762 | 763 | | |
763 | 764 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 20 | | |
31 | | - | |
| 21 | + | |
32 | 22 | | |
33 | 23 | | |
34 | 24 | | |
| |||
42 | 32 | | |
43 | 33 | | |
44 | 34 | | |
45 | | - | |
| 35 | + | |
46 | 36 | | |
47 | 37 | | |
48 | | - | |
| 38 | + | |
49 | 39 | | |
50 | 40 | | |
51 | 41 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 42 | + | |
| 43 | + | |
55 | 44 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 45 | | |
64 | 46 | | |
65 | 47 | | |
66 | | - | |
| 48 | + | |
67 | 49 | | |
68 | 50 | | |
69 | 51 | | |
| |||
103 | 85 | | |
104 | 86 | | |
105 | 87 | | |
106 | | - | |
107 | | - | |
| 88 | + | |
| 89 | + | |
108 | 90 | | |
109 | 91 | | |
110 | 92 | | |
| |||
116 | 98 | | |
117 | 99 | | |
118 | 100 | | |
119 | | - | |
120 | 101 | | |
121 | | - | |
122 | | - | |
| 102 | + | |
| 103 | + | |
123 | 104 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
127 | 108 | | |
128 | 109 | | |
129 | 110 | | |
130 | 111 | | |
131 | 112 | | |
132 | | - | |
133 | | - | |
| 113 | + | |
| 114 | + | |
134 | 115 | | |
135 | 116 | | |
136 | 117 | | |
| |||
142 | 123 | | |
143 | 124 | | |
144 | 125 | | |
| 126 | + | |
145 | 127 | | |
146 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
147 | 131 | | |
148 | 132 | | |
149 | 133 | | |
| |||
152 | 136 | | |
153 | 137 | | |
154 | 138 | | |
| 139 | + | |
155 | 140 | | |
156 | 141 | | |
157 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 148 | | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | 154 | | |
166 | 155 | | |
167 | 156 | | |
| |||
224 | 213 | | |
225 | 214 | | |
226 | 215 | | |
227 | | - | |
228 | | - | |
| 216 | + | |
| 217 | + | |
229 | 218 | | |
230 | 219 | | |
231 | 220 | | |
| |||
240 | 229 | | |
241 | 230 | | |
242 | 231 | | |
243 | | - | |
244 | | - | |
| 232 | + | |
| 233 | + | |
245 | 234 | | |
246 | 235 | | |
247 | 236 | | |
| |||
0 commit comments