Commit 0981b93
Refactor comprehensive demos to use coro::sync_wait instead of process_events
Replaced the spawn + process_events polling pattern with cleaner sync_wait
approach across all comprehensive demos for consistency and efficiency.
Changes:
- Refactored demo_task from CORO_TASK(void) to CORO_TASK(bool)
- Removed result_flag and completed_flag pointer parameters
- Replaced scheduler->spawn() + process_events() loop with coro::sync_wait()
- Added explicit scheduler->shutdown() calls to prevent thread leaks
Benefits:
- Cleaner, more maintainable code (-60 lines, +24 lines)
- Consistent pattern across all demos
- Proper thread cleanup via shutdown()
- More idiomatic coroutine usage
Files modified:
- demos/comprehensive/src/pointers/shared_ptr_demo.cpp
- demos/comprehensive/src/pointers/optimistic_ptr_demo.cpp
- demos/comprehensive/src/transport/local_transport_demo.cpp
- demos/comprehensive/src/transport/tcp_transport_demo.cpp
- demos/comprehensive/src/serialisation/serialisation_demo.cpp
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent f1a8d4e commit 0981b93
File tree
5 files changed
+37
-70
lines changed- demos/comprehensive/src
- pointers
- serialisation
- transport
5 files changed
+37
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | | - | |
277 | | - | |
| 276 | + | |
278 | 277 | | |
279 | 278 | | |
280 | 279 | | |
281 | 280 | | |
282 | 281 | | |
283 | 282 | | |
284 | | - | |
285 | | - | |
286 | | - | |
| 283 | + | |
287 | 284 | | |
288 | 285 | | |
289 | 286 | | |
| |||
345 | 342 | | |
346 | 343 | | |
347 | 344 | | |
348 | | - | |
349 | | - | |
| 345 | + | |
350 | 346 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 347 | + | |
357 | 348 | | |
358 | 349 | | |
359 | 350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | | - | |
221 | | - | |
| 220 | + | |
222 | 221 | | |
223 | 222 | | |
224 | 223 | | |
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
228 | | - | |
229 | | - | |
230 | | - | |
| 227 | + | |
231 | 228 | | |
232 | 229 | | |
233 | 230 | | |
| |||
279 | 276 | | |
280 | 277 | | |
281 | 278 | | |
282 | | - | |
283 | | - | |
| 279 | + | |
284 | 280 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 281 | + | |
291 | 282 | | |
292 | 283 | | |
293 | 284 | | |
| |||
Lines changed: 6 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | | - | |
230 | | - | |
| 229 | + | |
231 | 230 | | |
232 | 231 | | |
233 | 232 | | |
234 | 233 | | |
235 | 234 | | |
236 | 235 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 236 | + | |
240 | 237 | | |
241 | 238 | | |
242 | 239 | | |
| |||
285 | 282 | | |
286 | 283 | | |
287 | 284 | | |
288 | | - | |
289 | | - | |
| 285 | + | |
290 | 286 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 287 | + | |
297 | 288 | | |
298 | 289 | | |
299 | 290 | | |
| |||
Lines changed: 6 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
158 | 157 | | |
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
166 | | - | |
| 163 | + | |
167 | 164 | | |
168 | 165 | | |
169 | 166 | | |
| |||
214 | 211 | | |
215 | 212 | | |
216 | 213 | | |
217 | | - | |
218 | | - | |
| 214 | + | |
219 | 215 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 216 | + | |
226 | 217 | | |
227 | 218 | | |
228 | 219 | | |
| |||
Lines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
298 | | - | |
299 | | - | |
| 299 | + | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| 304 | + | |
| 305 | + | |
303 | 306 | | |
304 | 307 | | |
305 | 308 | | |
0 commit comments