pmmp / ext-pmmpthread

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

Thread & Worker should not be ThreadSafe objects #141

Open dktapps opened 6 months ago

dktapps commented 6 months ago

It doesn't really make any sense for these objects to be shared. They contain API methods which are only intended for the parent thread to use, such as start(), join(), isRunning(), isJoined(), etc.

The only reason a shared context object is desirable for these things is to allow Thread::run() to get information from the parent thread. After the initial run(), it makes more sense to put things in static properties, rather than paying a performance penalty to access them from the thread context again and again.

Proposal: