Skip to content

Commit 376d3f9

Browse files
authored
Document changes related to Fibers and destructors (#4060)
1 parent cb7c0c0 commit 376d3f9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

language/fibers.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
</para>
3737
<note>
3838
<simpara>
39-
Due to current limitations it is not possible to switch fibers in the destructor of an object.
39+
Prior to PHP 8.4.0, switching fibers during the execution of an object
40+
<link linkend="language.oop5.decon.destructor">destructor</link> was not
41+
allowed.
4042
</simpara>
4143
</note>
4244

language/oop5/decon.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,26 @@ $obj = new MyDestructableClass();
343343
<function>exit</function>. Calling <function>exit</function> in a destructor
344344
will prevent the remaining shutdown routines from executing.
345345
</para>
346+
<para>
347+
If a destructor creates new references to its object, it will not be called
348+
a second time when the reference count reaches zero again or during the
349+
shutdown sequence.
350+
</para>
351+
<para>
352+
As of PHP 8.4.0, when
353+
<link linkend="features.gc.collecting-cycles">cycle collection</link>
354+
occurs during the execution of a
355+
<link linkend="language.fibers">Fiber</link>, the destructors of objects
356+
scheduled for collection are executed in a separate Fiber, called the
357+
<literal>gc_destructor_fiber</literal>.
358+
If this Fiber is suspended, a new one will be created to execute any
359+
remaining destructors.
360+
The previous <literal>gc_destructor_fiber</literal> will no longer be
361+
referenced by the garbage collector and may be collected if it is not
362+
referenced elsewhere.
363+
Objects whose destructor are suspended will not be collected until the
364+
destructor returns or the Fiber itself is collected.
365+
</para>
346366
<note>
347367
<para>
348368
Destructors called during the script shutdown have HTTP headers already

0 commit comments

Comments
 (0)