r/PHPhelp • u/Tefkal1on • Jul 29 '25
php_context
https://github.com/Pashgunt/php_context
I present my implementation of Context implemented as an extension for php in C, if you think it might be useful or have any suggestions, please rate
5
Upvotes
View all comments
Show parent comment
2
u/Tefkal1on Jul 30 '25
Thank you, yes, you're right, but there are some nuances.
A PHP class can only check the time inside a single thread.
The C extension can actually run an additional native thread (or timer) that monitors the timeout regardless of the execution of the PHP code.
This makes it possible to externally interrupt execution (for example, by setting a flag that will be checked inside a loop or wrapper), even if a heavy operation is underway inside the callback. Saving resources and speed.
Plus, this is not the final version of the extension, I decided to find out if it really would make sense to expand this solution further.