Commit 6b01fed
committed
[Concurrency] Retain the actor around the CAS in enqueue() when necessary.
It's possible that the job we enqueue holds the last strong reference to the actor. If that job runs on another thread after we enqueue it, then it's possible for `this` to be destroyed while we're still in this function. We need to use `this` after the enqueue when the priorities don't match. When it looks like that will happen, retain `this` before the enqueue to ensure it stays alive until we're done with it.
Introduce a defensive retain helper class that makes it easy to do a single retain under certain conditions even in a loop, and does RAII to balance it with a release when the scope exits.
rdar://1354009331 parent 700493e commit 6b01fed
File tree
2 files changed
+73
-3
lines changed- include/swift/Runtime
- stdlib/public/Concurrency
2 files changed
+73
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
389 | 440 | | |
390 | 441 | | |
391 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1357 | 1357 | | |
1358 | 1358 | | |
1359 | 1359 | | |
| 1360 | + | |
1360 | 1361 | | |
1361 | 1362 | | |
1362 | 1363 | | |
| |||
1386 | 1387 | | |
1387 | 1388 | | |
1388 | 1389 | | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
1389 | 1400 | | |
1390 | 1401 | | |
1391 | 1402 | | |
1392 | 1403 | | |
1393 | 1404 | | |
1394 | 1405 | | |
1395 | 1406 | | |
1396 | | - | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
1397 | 1410 | | |
| 1411 | + | |
| 1412 | + | |
1398 | 1413 | | |
1399 | 1414 | | |
1400 | 1415 | | |
| |||
1405 | 1420 | | |
1406 | 1421 | | |
1407 | 1422 | | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1408 | 1426 | | |
1409 | 1427 | | |
1410 | 1428 | | |
| |||
1414 | 1432 | | |
1415 | 1433 | | |
1416 | 1434 | | |
1417 | | - | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
1418 | 1438 | | |
1419 | 1439 | | |
1420 | 1440 | | |
1421 | | - | |
1422 | 1441 | | |
1423 | 1442 | | |
1424 | 1443 | | |
| |||
0 commit comments