@@ -28,7 +28,7 @@ class Context
2828 */
2929 public static function getApp ()
3030 {
31- return static ::$ apps [static ::getCoroutineId ()] ?? null ;
31+ return static ::$ apps [static ::getRequestedCoroutineId ()] ?? null ;
3232 }
3333
3434 /**
@@ -38,7 +38,7 @@ public static function getApp()
3838 */
3939 public static function setApp (Container $ app )
4040 {
41- static ::$ apps [static ::getCoroutineId ()] = $ app ;
41+ static ::$ apps [static ::getRequestedCoroutineId ()] = $ app ;
4242 }
4343
4444 /**
@@ -50,7 +50,7 @@ public static function setApp(Container $app)
5050 */
5151 public static function getData (string $ key )
5252 {
53- return static ::$ data [static ::getCoroutineId ()][$ key ] ?? null ;
53+ return static ::$ data [static ::getRequestedCoroutineId ()][$ key ] ?? null ;
5454 }
5555
5656 /**
@@ -61,7 +61,7 @@ public static function getData(string $key)
6161 */
6262 public static function setData (string $ key , $ value )
6363 {
64- static ::$ data [static ::getCoroutineId ()][$ key ] = $ value ;
64+ static ::$ data [static ::getRequestedCoroutineId ()][$ key ] = $ value ;
6565 }
6666
6767 /**
@@ -71,38 +71,43 @@ public static function setData(string $key, $value)
7171 */
7272 public static function removeData (string $ key )
7373 {
74- unset(static ::$ data [static ::getCoroutineId ()][$ key ]);
74+ unset(static ::$ data [static ::getRequestedCoroutineId ()][$ key ]);
7575 }
7676
7777 /**
7878 * Get data keys by current coroutine id.
7979 */
8080 public static function getDataKeys ()
8181 {
82- return array_keys (static ::$ data [static ::getCoroutineId ()] ?? []);
82+ return array_keys (static ::$ data [static ::getRequestedCoroutineId ()] ?? []);
8383 }
8484
8585 /**
8686 * Clear data by current coroutine id.
8787 */
8888 public static function clear ()
8989 {
90- unset(static ::$ apps [static ::getCoroutineId ()]);
91- unset(static ::$ data [static ::getCoroutineId ()]);
90+ unset(static ::$ apps [static ::getRequestedCoroutineId ()]);
91+ unset(static ::$ data [static ::getRequestedCoroutineId ()]);
92+ }
93+
94+ public static function getCoroutineId (): int
95+ {
96+ return Coroutine::getuid ();
9297 }
9398
9499 /**
95- * Get current requesting coroutine id.
100+ * Get current coroutine id.
96101 */
97- public static function getCoroutineId (): int
102+ public static function getRequestedCoroutineId (): int
98103 {
99- $ currentId = Coroutine:: getuid ();
104+ $ currentId = static :: getCoroutineId ();
100105 if ($ currentId === -1 ) {
101106 return -1 ;
102107 }
103108
104109 $ counter = 0 ;
105- while (($ topCoroutineId = Coroutine::getPcid ($ currentId )) !== -1 && $ counter <= self ::MAX_RECURSE_COROUTINE_ID ) {
110+ while (($ topCoroutineId = Coroutine::getPcid ($ currentId )) !== -1 && $ counter <= static ::MAX_RECURSE_COROUTINE_ID ) {
106111 $ currentId = $ topCoroutineId ;
107112 $ counter ++;
108113 }
0 commit comments