Commit 312476c
async_hooks: add using scopes to AsyncLocalStorage
Adds support for using scope = storage.withScope(data) to do
the equivalent of a storage.run(data, fn) with using syntax.
This enables avoiding unnecessary closures.
PR-URL: #61674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>1 parent 6c6c900 commit 312476cCopy full SHA for 312476c
5 files changed
+409Lines changed: 409 additions & 0 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- doc/api
- lib/internal/async_local_storage
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+164Lines changed: 164 additions & 0 deletions
- Display the source diff
- Display the rich diff
| 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 | + |
| 440 | + |
| 441 | + |
| 442 | + |
| 443 | + |
| 444 | + |
| 445 | + |
| 446 | + |
| 447 | + |
| 448 | + |
| 449 | + |
| 450 | + |
| 451 | + |
| 452 | + |
| 453 | + |
| 454 | + |
| 455 | + |
| 456 | + |
| 457 | + |
| 458 | + |
| 459 | + |
| 460 | + |
| 461 | + |
| 462 | + |
| 463 | + |
| 464 | + |
| 465 | + |
| 466 | + |
| 467 | + |
| 468 | + |
| 469 | + |
| 470 | + |
| 471 | + |
| 472 | + |
| 473 | + |
| 474 | + |
| 475 | + |
| 476 | + |
| 477 | + |
| 478 | + |
| 479 | + |
| 480 | + |
| 481 | + |
| 482 | + |
| 483 | + |
| 484 | + |
| 485 | + |
| 486 | + |
| 487 | + |
| 488 | + |
| 489 | + |
| 490 | + |
| 491 | + |
| 492 | + |
389 | 493 | |
390 | 494 | |
391 | 495 | |
| ||
420 | 524 | |
421 | 525 | |
422 | 526 | |
| 527 | + |
| 528 | + |
| 529 | + |
| 530 | + |
| 531 | + |
| 532 | + |
| 533 | + |
| 534 | + |
| 535 | + |
| 536 | + |
| 537 | + |
| 538 | + |
| 539 | + |
| 540 | + |
| 541 | + |
| 542 | + |
| 543 | + |
| 544 | + |
| 545 | + |
| 546 | + |
| 547 | + |
| 548 | + |
| 549 | + |
| 550 | + |
| 551 | + |
| 552 | + |
| 553 | + |
| 554 | + |
| 555 | + |
| 556 | + |
| 557 | + |
| 558 | + |
| 559 | + |
| 560 | + |
| 561 | + |
| 562 | + |
| 563 | + |
| 564 | + |
| 565 | + |
| 566 | + |
| 567 | + |
| 568 | + |
| 569 | + |
| 570 | + |
| 571 | + |
| 572 | + |
| 573 | + |
| 574 | + |
| 575 | + |
| 576 | + |
| 577 | + |
| 578 | + |
| 579 | + |
| 580 | + |
| 581 | + |
| 582 | + |
| 583 | + |
| 584 | + |
423 | 585 | |
424 | 586 | |
425 | 587 | |
| ||
905 | 1067 | |
906 | 1068 | |
907 | 1069 | |
| 1070 | + |
908 | 1071 | |
909 | 1072 | |
910 | 1073 | |
911 | 1074 | |
| 1075 | + |
912 | 1076 | |
Collapse file
lib/internal/async_local_storage/async_context_frame.js
Copy file name to clipboardExpand all lines: lib/internal/async_local_storage/async_context_frame.js+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
| 15 | + |
| 16 | + |
15 | 17 | |
16 | 18 | |
17 | 19 | |
| ||
77 | 79 | |
78 | 80 | |
79 | 81 | |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
80 | 86 | |
81 | 87 | |
82 | 88 | |
Collapse file
lib/internal/async_local_storage/async_hooks.js
Copy file name to clipboardExpand all lines: lib/internal/async_local_storage/async_hooks.js+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
19 | 19 | |
20 | 20 | |
21 | 21 | |
| 22 | + |
| 23 | + |
22 | 24 | |
23 | 25 | |
24 | 26 | |
| ||
142 | 144 | |
143 | 145 | |
144 | 146 | |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
145 | 151 | |
146 | 152 | |
147 | 153 | |
Collapse file
lib/internal/async_local_storage/run_scope.js
Copy file name to clipboard+31Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
0 commit comments