File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,34 @@ public function testSuspensionWithinCallback(): void
199
199
}
200
200
201
201
public function testSuspensionWithinCallbackGarbageCollection (): void
202
+ {
203
+ $ memory = 0 ;
204
+ $ i = 0 ;
205
+
206
+ EventLoop::repeat (0.001 , static function (string $ id ) use (&$ memory , &$ i ) {
207
+ $ suspension = EventLoop::getSuspension ();
208
+ EventLoop::defer (static fn () => $ suspension ->resume ());
209
+ $ suspension ->suspend ();
210
+
211
+ if (++$ i % 250 === 0 ) {
212
+ \gc_collect_cycles ();
213
+
214
+ if ($ memory > 0 ) {
215
+ self ::assertSame ($ memory , \memory_get_usage ());
216
+ }
217
+
218
+ $ memory = \memory_get_usage ();
219
+ }
220
+
221
+ if ($ i === 10000 ) {
222
+ EventLoop::cancel ($ id );
223
+ }
224
+ });
225
+
226
+ EventLoop::run ();
227
+ }
228
+
229
+ public function testSuspensionWithinCallbackGarbageCollectionSuspended (): void
202
230
{
203
231
EventLoop::defer (static function () use (&$ finally ): void {
204
232
$ suspension = EventLoop::getSuspension ();
You can’t perform that action at this time.
0 commit comments