PHP threads (pthreads) work, but no Stackable class

the last few days I have been using PHP threads (pthreads) with PHP 7.0.1 (with -enable-maintainer-zts in configure), and everything works fine when using Thread or Worker. When I tried to create a class that inherits from Stackable for Worker, I got "Fatal error: Class" Stackable "not found".

With get_declared_classes (), I realized that for the threads I only had the Threaded, Volatile, Thread, Worker and Pool classes. I thought this was a problem with the pthreads version (it was the latest version 3.1.15), but there was an error uninstalling it and setting it back to 3.0.0.

Also, the PHP manual (in English) does not mention the Stackable class, although it is important to do Worker's work. What am I missing here?

+4
source share
2 answers

I will answer my question. It looks like the PHP manual has not been updated. You do not need Stackable to get Worker (or even Pool) to work. It can only be a Threaded object. To learn about the latest implementation of threads in PHP via pthreads, read https://github.com/krakjoe/pthreads , as well as examples and tests there. Joe Watkins' work is really wonderful, and as a programmer, I feel the need to thank him. But updating the PHP manual would be wonderful and even a reference that it is out of date.

+3
source

Stackable is only an alias for Threaded since 2.0.0. Therefore, you are better off using the Threaded class.

pthreads.

+1

Source: https://habr.com/ru/post/1622643/


All Articles