krakjoe / pthreads

Threading for PHP - Share Nothing, Do Everything :)
Other
3.47k stars 501 forks source link

Streams support #911

Open sirsnyder opened 5 years ago

sirsnyder commented 5 years ago

This is a thread-safe port of the php streams layer, including wrappers, transports and filters. Resources were replaced by objects and the following new classes introduced.

See stub.php. A File class definition in global scope will be a huge BC break though. Maybe we will find another name or introduce a namespace, whatever that looks like.

Predefined wrappers

Predefined filters

Todo

What's next? Removal of Todos for sure. I would like to publish this in a timely manner as prerelease in a separate branch to get audience and feedback. Possibly with other BC breaking changes like #906 and the behavior of static members initialization.

On top of this PR a port of the openssl "ssl" wrapper will follow.

@tpunt @dktapps Thoughts, questions?

Big thanks to the team behind php-src!

tpunt commented 5 years ago

Great work @SirSnyder! I'll try to get around to reviewing the code some time soon, as well as give some feedback on the API exposed.

dktapps commented 5 years ago

This looks interesting for sure, but I'm doubtful about the merits of replicating half of PHP into pthreads. As far as I knew, php-src are planning to kill off resources anyway.

I haven't looked closely at the diff yet, so please excuse me if I said something wrong.

sirsnyder commented 5 years ago

I understand the concerns, it will be a lot more code to care about. Nevertheless it is a great opportunity for pthreads, we can build many things up on streams. I heard two years ago for the first time, that resources should be replaced. To be honest, I think that will never happen and end like php 6 in the distant future. That task is huge, it's massive. Beside the core, API, every bundled and external extension dealing with resources have to replace them too. The db extensions are no fun, really. Even if I'm wrong, which would be great, implementation and data handling must be thread-safe. Objects only are not enough.