File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ BasedOnStyle : WebKit
3+ SortIncludes : ' false'
4+ ColumnLimit : 100
5+ IndentWidth : 4
6+ TabWidth : 4
7+ ContinuationIndentWidth : 8
8+ UseTab : ForContinuationAndIndentation
9+ PointerAlignment : Right
10+ IndentCaseLabels : true
11+ AlignConsecutiveAssignments : false
12+ AlignEscapedNewlines : DontAlign
13+ AllowShortFunctionsOnASingleLine : false
14+ SpaceAfterCStyleCast : true
15+ AlignOperands : false
16+ ...
Original file line number Diff line number Diff line change 2222#include "exceptions.h"
2323#include "scope.h"
2424#include "zend_common.h"
25+ #include "zend_observer.h"
26+
27+ static zend_function main_coroutine_root_function = { ZEND_INTERNAL_FUNCTION };
2528
2629void async_scheduler_startup (void )
2730{
@@ -610,6 +613,19 @@ void async_scheduler_launch(void)
610613 main_transfer -> flags = 0 ;
611614 ZVAL_NULL (& main_transfer -> value );
612615
616+ //
617+ // Because the main coroutine is created on the fly, this code is here.
618+ // At the moment when PHP decides to activate the scheduler,
619+ // we must normalize the observer's state and notify it that we are creating the main coroutine.
620+ //
621+ // This code contains a logical conflict because main_transfer is, in a way, the context of the zero coroutine.
622+ // It's essentially a switch from the zero context to the coroutine context, even though,
623+ // logically, both contexts belong to the main execution thread.
624+ //
625+ main_coroutine -> context .status = ZEND_FIBER_STATUS_INIT ;
626+ zend_observer_fiber_switch_notify (main_transfer -> context , & main_coroutine -> context );
627+ main_coroutine -> context .status = ZEND_FIBER_STATUS_RUNNING ;
628+
613629 ASYNC_G (main_transfer ) = main_transfer ;
614630 ASYNC_G (main_vm_stack ) = EG (vm_stack );
615631
You can’t perform that action at this time.
0 commit comments