4

last few days I am using PHP threads (pthreads) with PHP 7.0.1 (with –enable-maintainer-zts in the configure) and all works well when using Thread or Worker. When I tried to create a class that inherits from Stackable for a Worker I got “Fatal error: Class 'Stackable' not found” .

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

Also the PHP manual (in English) doesn't mention the Stackable class although it is essential to make a Worker work. What am I missing here?

jkon
  • 191
  • 7

2 Answers2

3

I will answer my own question . It seems that the PHP manual has not been updated. You don't need a Stackable to make a Worker (or even a Pool) work. It could be just a Threaded object. To learn about the latest implementation of threads in PHP through pthreads read https://github.com/krakjoe/pthreads and also the examples and tests there. The work of Joe Watkins is really admirable and as a programmer I feel the need to thank him. But updating the PHP manual would be great also , or even a reference there , that it is out of date.

jkon
  • 191
  • 7
2

Stackable is only an alias for Threaded since 2.0.0. So you should better use Threaded class.

See this pthreads issue.

Vic
  • 21,473
  • 11
  • 76
  • 97
u-nik
  • 488
  • 4
  • 12