Commit 41e6fe7
Add get_only_safe_from_non_presenting_sta() to async operations
Add a peer to .get() on IAsyncAction, IAsyncOperation, IAsyncActionWithProgress,
and IAsyncOperationWithProgress that skips the _DEBUG-only STA blocking assert.
The existing .get() asserts !is_sta_thread() to guard against blocking UI threads.
However, not all STAs are UI threads — some never present UI, haven't presented yet,
or never will. The assert is also _DEBUG-only, making it invisible to codebases that
don't build with _DEBUG (e.g. the Windows OS).
The new method get_only_safe_from_non_presenting_sta() is functionally identical to
.get() but omits the STA check. The intentionally long name communicates the risk
to callers.
Changes:
- strings/base_coroutine_foundation.h: Add wait_get_bypass_sta_check() impl helper
and get_only_safe_from_non_presenting_sta() for all 4 async consume templates
- cppwinrt/code_writers.h: Add declaration to generated code for all 4 async types
- test/test_nocoro: Add test calling the new method from an STA thread using a
real WinRT async operation (PathIO::ReadTextAsync on C:\Windows\win.ini)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent f23b41e commit 41e6fe7
File tree
4 files changed
+71
-0
lines changed- cppwinrt
- strings
- test/test_nocoro
4 files changed
+71
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1433 | 1433 | | |
1434 | 1434 | | |
1435 | 1435 | | |
| 1436 | + | |
1436 | 1437 | | |
1437 | 1438 | | |
1438 | 1439 | | |
1439 | 1440 | | |
1440 | 1441 | | |
1441 | 1442 | | |
| 1443 | + | |
1442 | 1444 | | |
1443 | 1445 | | |
1444 | 1446 | | |
1445 | 1447 | | |
1446 | 1448 | | |
1447 | 1449 | | |
| 1450 | + | |
1448 | 1451 | | |
1449 | 1452 | | |
1450 | 1453 | | |
1451 | 1454 | | |
1452 | 1455 | | |
1453 | 1456 | | |
| 1457 | + | |
1454 | 1458 | | |
1455 | 1459 | | |
1456 | 1460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
102 | 115 | | |
103 | 116 | | |
104 | 117 | | |
| |||
220 | 233 | | |
221 | 234 | | |
222 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
223 | 241 | | |
224 | 242 | | |
225 | 243 | | |
| |||
231 | 249 | | |
232 | 250 | | |
233 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
234 | 257 | | |
235 | 258 | | |
236 | 259 | | |
| |||
242 | 265 | | |
243 | 266 | | |
244 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
245 | 273 | | |
246 | 274 | | |
247 | 275 | | |
| |||
253 | 281 | | |
254 | 282 | | |
255 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
256 | 289 | | |
257 | 290 | | |
258 | 291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
0 commit comments