Commit 586aaa7
committed
select: Enable timeout on select when PROXY_TO_PTHREAD
This commit enables the select syscall to handle timeout with multiple event
sources. PROXY_TO_PTHREAD is needed to prevent blocking the main worker.
When a thread worker invokes the select syscall with non-zero timeout and no
fd is ready, it blocks using Atmoics.wait until it receives a readiness
notification. On the main worker, the underlying stream implementation can
trigger readiness using Atomics.notify through a callback. A notification
also issued automatically once the specified timeout expires.
Communication between the thread worker and the main worker occurs via
a shared memory region. To prevent a select invocation being unblocked by
the callbacks of a previous invocation, all active callbacks are tracked in
a list. See the comments in activeSelectCallbacks for details.
Usage of the notification callback is optional. If the stream implementation
doesn't support it, the "poll" method can still synchronously return the
event status.
Signed-off-by: Kohei Tokunaga <[email protected]>1 parent bc1913e commit 586aaa7
2 files changed
+122
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
577 | 582 | | |
578 | 583 | | |
579 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
580 | 588 | | |
581 | 589 | | |
582 | 590 | | |
| |||
621 | 629 | | |
622 | 630 | | |
623 | 631 | | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
624 | 675 | | |
625 | 676 | | |
626 | 677 | | |
| |||
648 | 699 | | |
649 | 700 | | |
650 | 701 | | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
651 | 705 | | |
652 | 706 | | |
653 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
| 610 | + | |
| 611 | + | |
610 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
611 | 639 | | |
612 | 640 | | |
613 | 641 | | |
| |||
633 | 661 | | |
634 | 662 | | |
635 | 663 | | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
636 | 692 | | |
637 | 693 | | |
638 | 694 | | |
| |||
644 | 700 | | |
645 | 701 | | |
646 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
647 | 706 | | |
| 707 | + | |
648 | 708 | | |
649 | 709 | | |
650 | 710 | | |
651 | 711 | | |
652 | 712 | | |
653 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
654 | 721 | | |
| 722 | + | |
655 | 723 | | |
656 | 724 | | |
657 | 725 | | |
| |||
0 commit comments