@@ -19,26 +19,35 @@ class WorkStealingDispatcherTest {
1919 val dispatcher = WorkStealingDispatcher (Dispatchers .Unconfined )
2020
2121 expect(0 )
22- dispatcher.dispatch(dispatcher, Runnable {
23- expect(1 )
24- })
22+ dispatcher.dispatch(
23+ dispatcher,
24+ Runnable {
25+ expect(1 )
26+ }
27+ )
2528 expect(2 )
2629 }
2730
2831 @Test fun dispatchNested_enqueuesWhenDelegateIsUnconfined () {
2932 val dispatcher = WorkStealingDispatcher (Dispatchers .Unconfined )
3033
3134 expect(0 )
32- dispatcher.dispatch(dispatcher, Runnable {
33- expect(1 )
34-
35- // This dispatch should get enqueued to Unconfined's threadlocal queue.
36- dispatcher.dispatch(dispatcher, Runnable {
37- expect(3 )
38- })
39-
40- expect(2 )
41- })
35+ dispatcher.dispatch(
36+ dispatcher,
37+ Runnable {
38+ expect(1 )
39+
40+ // This dispatch should get enqueued to Unconfined's threadlocal queue.
41+ dispatcher.dispatch(
42+ dispatcher,
43+ Runnable {
44+ expect(3 )
45+ }
46+ )
47+
48+ expect(2 )
49+ }
50+ )
4251
4352 expect(4 )
4453 }
@@ -48,9 +57,12 @@ class WorkStealingDispatcherTest {
4857 val dispatcher = WorkStealingDispatcher (testDispatcher)
4958
5059 expect(0 )
51- dispatcher.dispatch(dispatcher, Runnable {
52- expect(2 )
53- })
60+ dispatcher.dispatch(
61+ dispatcher,
62+ Runnable {
63+ expect(2 )
64+ }
65+ )
5466 expect(1 )
5567
5668 testDispatcher.scheduler.advanceUntilIdle()
@@ -62,13 +74,19 @@ class WorkStealingDispatcherTest {
6274 val dispatcher = WorkStealingDispatcher (testDispatcher)
6375
6476 expect(0 )
65- dispatcher.dispatch(dispatcher, Runnable {
66- expect(3 )
67- })
77+ dispatcher.dispatch(
78+ dispatcher,
79+ Runnable {
80+ expect(3 )
81+ }
82+ )
6883 expect(1 )
69- dispatcher.dispatch(dispatcher, Runnable {
70- expect(4 )
71- })
84+ dispatcher.dispatch(
85+ dispatcher,
86+ Runnable {
87+ expect(4 )
88+ }
89+ )
7290 expect(2 )
7391
7492 testDispatcher.scheduler.advanceUntilIdle()
@@ -80,19 +98,28 @@ class WorkStealingDispatcherTest {
8098 val dispatcher = WorkStealingDispatcher (testDispatcher)
8199
82100 expect(0 )
83- dispatcher.dispatch(dispatcher, Runnable {
84- expect(2 )
85- dispatcher.dispatch(dispatcher, Runnable {
86- expect(5 )
87- })
101+ dispatcher.dispatch(
102+ dispatcher,
103+ Runnable {
104+ expect(2 )
105+ dispatcher.dispatch(
106+ dispatcher,
107+ Runnable {
108+ expect(5 )
109+ }
110+ )
88111
89- expect(3 )
112+ expect(3 )
90113
91- dispatcher.dispatch(dispatcher, Runnable {
92- expect(6 )
93- })
94- expect(4 )
95- })
114+ dispatcher.dispatch(
115+ dispatcher,
116+ Runnable {
117+ expect(6 )
118+ }
119+ )
120+ expect(4 )
121+ }
122+ )
96123 expect(1 )
97124
98125 testDispatcher.scheduler.advanceUntilIdle()
@@ -164,12 +191,18 @@ class WorkStealingDispatcherTest {
164191 val dispatcher = WorkStealingDispatcher (testDispatcher)
165192
166193 expect(0 )
167- dispatcher.dispatch(dispatcher, Runnable {
168- expect(2 )
169- })
170- dispatcher.dispatch(dispatcher, Runnable {
171- expect(3 )
172- })
194+ dispatcher.dispatch(
195+ dispatcher,
196+ Runnable {
197+ expect(2 )
198+ }
199+ )
200+ dispatcher.dispatch(
201+ dispatcher,
202+ Runnable {
203+ expect(3 )
204+ }
205+ )
173206 expect(1 )
174207
175208 dispatcher.advanceUntilIdle()
@@ -181,13 +214,19 @@ class WorkStealingDispatcherTest {
181214 val dispatcher = WorkStealingDispatcher (testDispatcher)
182215
183216 expect(0 )
184- dispatcher.dispatch(dispatcher, Runnable {
185- expect(2 )
186- dispatcher.dispatch(dispatcher, Runnable {
187- expect(4 )
188- })
189- expect(3 )
190- })
217+ dispatcher.dispatch(
218+ dispatcher,
219+ Runnable {
220+ expect(2 )
221+ dispatcher.dispatch(
222+ dispatcher,
223+ Runnable {
224+ expect(4 )
225+ }
226+ )
227+ expect(3 )
228+ }
229+ )
191230 expect(1 )
192231
193232 dispatcher.advanceUntilIdle()
@@ -199,21 +238,30 @@ class WorkStealingDispatcherTest {
199238 val dispatcher = WorkStealingDispatcher (testDispatcher)
200239
201240 expect(0 )
202- dispatcher.dispatch(dispatcher, Runnable {
203- expect(2 )
204- dispatcher.dispatch(dispatcher, Runnable {
205- expect(4 )
206- })
207- expect(3 )
241+ dispatcher.dispatch(
242+ dispatcher,
243+ Runnable {
244+ expect(2 )
245+ dispatcher.dispatch(
246+ dispatcher,
247+ Runnable {
248+ expect(4 )
249+ }
250+ )
251+ expect(3 )
208252
209- dispatcher.advanceUntilIdle()
253+ dispatcher.advanceUntilIdle()
210254
211- expect(5 )
212- dispatcher.dispatch(dispatcher, Runnable {
213- expect(7 )
214- })
215- expect(6 )
216- })
255+ expect(5 )
256+ dispatcher.dispatch(
257+ dispatcher,
258+ Runnable {
259+ expect(7 )
260+ }
261+ )
262+ expect(6 )
263+ }
264+ )
217265 expect(1 )
218266
219267 dispatcher.advanceUntilIdle()
0 commit comments