Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document changes related to Fibers and destructors #4060

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion language/fibers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
</para>
<note>
<simpara>
Due to current limitations it is not possible to switch fibers in the destructor of an object.
Prior to PHP 8.4.0, switching fibers during the execution of an object
<link linkend="language.oop5.decon.destructor">destructor</link> was not
allowed.
</simpara>
</note>

Expand Down
20 changes: 20 additions & 0 deletions language/oop5/decon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,26 @@ $obj = new MyDestructableClass();
<function>exit</function>. Calling <function>exit</function> in a destructor
will prevent the remaining shutdown routines from executing.
</para>
<para>
If a destructor creates new references to its object, it will not be called
a second time when the reference count reaches zero again or during the
shutdown sequence.
</para>
Comment on lines +346 to +350
Copy link
Member Author

@arnaud-lb arnaud-lb Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is not new behavior, but I felt it was missing

<para>
As of PHP 8.4.0, when
<link linkend="features.gc.collecting-cycles">cycle collection</link>
occurs during the execution of a
<link linkend="language.fibers">Fiber</link>, the destructors of objects
scheduled for collection are executed in a separate Fiber, called the
<literal>gc_destructor_fiber</literal>.
If this Fiber is suspended, a new one will be created to execute any
remaining destructors.
The previous <literal>gc_destructor_fiber</literal> will no longer be
referenced by the garbage collector and may be collected if it is not
referenced elsewhere.
Objects whose destructor are suspended will not be collected until the
destructor returns or the Fiber itself is collected.
</para>
<note>
<para>
Destructors called during the script shutdown have HTTP headers already
Expand Down