Commit ccf2f93
committed
Add global main coroutine switch handlers API for context isolation
Introduces API for registering global switch handlers that are automatically
attached to the main coroutine when the scheduler starts lazily. This enables
modules to set up proper context isolation (like output buffers) before any
coroutine execution begins.
Key features:
- Global handler registration with persistent memory allocation
- Automatic handler attachment to main coroutine on scheduler startup
- Proper cleanup during PHP shutdown
- Thread-safe execution protection
API functions:
- zend_async_add_main_coroutine_start_handler()
- zend_async_call_main_coroutine_start_handlers()
- Corresponding ZEND_ASYNC_ADD_MAIN_COROUTINE_START_HANDLER macros
This solves the chicken-and-egg problem where modules need to initialize
context before the scheduler creates the main coroutine, enabling proper
isolation of global state like output buffers between coroutines.1 parent c152009 commit ccf2f93
2 files changed
+31
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
158 | 166 | | |
159 | 167 | | |
160 | 168 | | |
| |||
241 | 249 | | |
242 | 250 | | |
243 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
244 | 257 | | |
245 | 258 | | |
246 | 259 | | |
| |||
609 | 622 | | |
610 | 623 | | |
611 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
612 | 628 | | |
613 | 629 | | |
614 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
| 742 | + | |
| 743 | + | |
742 | 744 | | |
743 | 745 | | |
744 | 746 | | |
745 | 747 | | |
746 | 748 | | |
747 | | - | |
748 | | - | |
| 749 | + | |
| 750 | + | |
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
752 | 754 | | |
753 | 755 | | |
754 | 756 | | |
755 | 757 | | |
756 | | - | |
757 | | - | |
| 758 | + | |
| 759 | + | |
758 | 760 | | |
759 | 761 | | |
760 | 762 | | |
761 | 763 | | |
762 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
763 | 770 | | |
764 | 771 | | |
765 | 772 | | |
| |||
830 | 837 | | |
831 | 838 | | |
832 | 839 | | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
833 | 844 | | |
834 | 845 | | |
835 | 846 | | |
| |||
0 commit comments