pmmp / ext-pmmpthread

Fork of https://github.com/krakjoe/pthreads with a revamped API and PHP 8.1+ support
Other
82 stars 15 forks source link

Thread::start() now requires options to be specified #114

Closed dktapps closed 1 year ago

dktapps commented 1 year ago

Since there's no one-size-fits-all for this, we require the user to specify it.

For single-file scripts, it'll usually be necessary to use INHERIT_ALL, since you'll probably want to use classes, functions and constants in the same file that can't be autoloaded. For production applications, which usually follow a one-class-per-file rule, INHERIT_NONE or INHERIT_INI is preferable, since these have significantly less overhead and use much less memory.

Unaddressed issues

dktapps commented 1 year ago

Another possible option might be to add some kind of INHERIT_LOCAL_CODE option, which inherits only the classes/functions/constants declared within the same file as the thread class itself. This seems like a workable option for both single-file scripts and PSR-style autoloaded applications.