Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16343 > unrolled thread

Fatal error: Class 'Stackable' not found in

Started byJames Wang <jwang25610@gmail.com>
First post2016-01-29 08:57 -0800
Last post2016-02-03 06:08 -0800
Articles 17 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-01-29 08:57 -0800
    Re: Fatal error: Class 'Stackable' not found in Jerry Stuckle <jstucklex@attglobal.net> - 2016-01-29 13:02 -0500
      Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-01-29 11:05 -0800
    Re: Fatal error: Class 'Stackable' not found in "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-01-29 20:03 +0100
      Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-01-29 11:08 -0800
        Re: Fatal error: Class 'Stackable' not found in "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-01-29 21:20 +0100
          Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-01-29 12:28 -0800
          Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-01 01:28 -0800
            Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-01 03:24 -0800
              Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-01 04:16 -0800
                Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-02 07:50 -0800
                  Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-03 01:35 -0800
                    Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-03 02:12 -0800
                      Re: Fatal error: Class 'Stackable' not found in Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-03 09:01 -0500
                      Re: Fatal error: Class 'Stackable' not found in Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-03 09:02 -0500
                        Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-03 06:06 -0800
                          Re: Fatal error: Class 'Stackable' not found in James Wang <jwang25610@gmail.com> - 2016-02-03 06:08 -0800

#16343 — Fatal error: Class 'Stackable' not found in

FromJames Wang <jwang25610@gmail.com>
Date2016-01-29 08:57 -0800
SubjectFatal error: Class 'Stackable' not found in
Message-ID<f186d6b3-fc64-4195-8678-4eda24312211@googlegroups.com>
Hi All,

I had this error and have googled a while now without joy.

Please would you shed some light.

php7 -m
[PHP Modules]
Core
ctype
date
dom
fileinfo
filter
hash
iconv
json
libxml
mysqli
mysqlnd
pcre
PDO
pdo_sqlite
Phar
posix
pthreads
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]

Do I miss a module?  I built PhP7 from source

Thanks a lot in advance

Code I run:
<?php
class Sum extends Stackable {
    private $value = 0;
    public function add($inc)  { $this->value += $inc; }
    public function getValue() { return $this->value; }
    public function run(){}
}

class MyThread extends Thread {
    public $sum;

    public function __construct(Sum $sum) {
        $this->sum = $sum;
    }

    public function run(){
        for ($i=0; $i < 10; $i++) {
            $this->sum->add(5);
            echo $this->sum->getValue() . " ";
        }
    }
}

$sum = new Sum();
$thread = new MyThread($sum);
$thread->start();
$thread->join();
echo $sum->getValue();
?>

James

[toc] | [next] | [standalone]


#16344

FromJerry Stuckle <jstucklex@attglobal.net>
Date2016-01-29 13:02 -0500
Message-ID<n8g99l$oo7$1@jstuckle.eternal-september.org>
In reply to#16343
On 1/29/2016 11:57 AM, James Wang wrote:
> Hi All,
> 
> I had this error and have googled a while now without joy.
> 
> Please would you shed some light.
> 
> php7 -m
> [PHP Modules]
> Core
> ctype
> date
> dom
> fileinfo
> filter
> hash
> iconv
> json
> libxml
> mysqli
> mysqlnd
> pcre
> PDO
> pdo_sqlite
> Phar
> posix
> pthreads
> Reflection
> session
> SimpleXML
> sockets
> SPL
> sqlite3
> standard
> tokenizer
> xml
> xmlreader
> xmlwriter
> 
> [Zend Modules]
> 
> Do I miss a module?  I built PhP7 from source
> 
> Thanks a lot in advance
> 
> Code I run:
> <?php
> class Sum extends Stackable {
>     private $value = 0;
>     public function add($inc)  { $this->value += $inc; }
>     public function getValue() { return $this->value; }
>     public function run(){}
> }
> 
> class MyThread extends Thread {
>     public $sum;
> 
>     public function __construct(Sum $sum) {
>         $this->sum = $sum;
>     }
> 
>     public function run(){
>         for ($i=0; $i < 10; $i++) {
>             $this->sum->add(5);
>             echo $this->sum->getValue() . " ";
>         }
>     }
> }
> 
> $sum = new Sum();
> $thread = new MyThread($sum);
> $thread->start();
> $thread->join();
> echo $sum->getValue();
> ?>
> 
> James
> 

James,

I haven't used Stackable, but it looks to be part of pthreads, which is
a PECL extension.  Did you install it?  Note there are certain
requirements for compiling PHP when using the pthreads extension.  See
http://php.net/manual/en/pthreads.requirements.php for more information.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#16346

FromJames Wang <jwang25610@gmail.com>
Date2016-01-29 11:05 -0800
Message-ID<e64be6e3-504f-4629-b254-b0ec3d13717d@googlegroups.com>
In reply to#16344
On Friday, 29 January 2016 18:02:15 UTC, Jerry Stuckle  wrote:
> James,
> 
> I haven't used Stackable, but it looks to be part of pthreads, which is
> a PECL extension.  Did you install it?  Note there are certain
> requirements for compiling PHP when using the pthreads extension.  See
> http://php.net/manual/en/pthreads.requirements.php for more information.
> jstucklex@attglobal.net

Hi Jerry,

I have installed the PECL pthreads extension (please see my post php -m output). Also, I can pass simple data types (string/boolean/int et al) to and from a thread.

A little googling told me that I needed Stackable class to pass an object/reference.  So I tried but failed with the error message as in the topic line.

Thanks for your attention.
James

[toc] | [prev] | [next] | [standalone]


#16345

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-01-29 20:03 +0100
Message-ID<n8gd27$h20$1@solani.org>
In reply to#16343
James Wang wrote:

> I had this error and have googled a while now without joy.
> 
> Please would you shed some light.
> 
> php7 -m
> [PHP Modules]
<snip>
> pthreads
<snip>
> 
> [Zend Modules]
> 
> Do I miss a module?  I built PhP7 from source

The pthreads API for v3 has changed substantially[1], what is not yet
documented in the PHP manual.  I *assume* that the Stackable class[2] is
not available anymore.

[1] <https://github.com/krakjoe/pthreads#php7>
[2] <http://php.net/manual/pl/class.stackable.php>

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#16347

FromJames Wang <jwang25610@gmail.com>
Date2016-01-29 11:08 -0800
Message-ID<20de60e7-9f92-49cf-ad1f-ae73e0bcb82c@googlegroups.com>
In reply to#16345
On Friday, 29 January 2016 19:03:45 UTC, Christoph M. Becker  wrote:
> James Wang wrote:
> 
> > I had this error and have googled a while now without joy.
> > 
> > Please would you shed some light.
> > 
> > php7 -m
> > [PHP Modules]
> <snip>
> > pthreads
> <snip>
> > 
> > [Zend Modules]
> > 
> > Do I miss a module?  I built PhP7 from source
> 
> The pthreads API for v3 has changed substantially[1], what is not yet
> documented in the PHP manual.  I *assume* that the Stackable class[2] is
> not available anymore.
> 
> [1] <https://github.com/krakjoe/pthreads#php7>
> [2] <http://php.net/manual/pl/class.stackable.php>
> 
> -- 
> Christoph M. Becker

Hi Chris,

Thanks a lot for this.

Any alternative please?  
I need to pass objects/references to and from a thread please.

Thanks indeed
James

[toc] | [prev] | [next] | [standalone]


#16348

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-01-29 21:20 +0100
Message-ID<n8ghie$28o$1@solani.org>
In reply to#16347
James Wang wrote:

> On Friday, 29 January 2016 19:03:45 UTC, Christoph M. Becker  wrote:
>>
>> The pthreads API for v3 has changed substantially[1], what is not yet
>> documented in the PHP manual.  I *assume* that the Stackable class[2] is
>> not available anymore.
> 
> Thanks a lot for this.
> 
> Any alternative please?  
> I need to pass objects/references to and from a thread please.

I have no experience with the pthreads extension, but it might be
possible to use the Threaded class[1] instead of Stackable.

[1] <http://php.net/manual/en/class.threaded.php>

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#16349

FromJames Wang <jwang25610@gmail.com>
Date2016-01-29 12:28 -0800
Message-ID<12fa34d1-d963-45ca-adbb-cbcc290bfbc8@googlegroups.com>
In reply to#16348
On Friday, 29 January 2016 20:20:38 UTC, Christoph M. Becker  wrote:
> > Any alternative please?  
> > I need to pass objects/references to and from a thread please.
> 
> I have no experience with the pthreads extension, but it might be
> possible to use the Threaded class[1] instead of Stackable.
> 
> [1] <http://php.net/manual/en/class.threaded.php>

Thanks a lot.  And shall try and update here.

[toc] | [prev] | [next] | [standalone]


#16350

FromJames Wang <jwang25610@gmail.com>
Date2016-02-01 01:28 -0800
Message-ID<b3b07343-420b-41ed-aad0-bec30f3e4cf8@googlegroups.com>
In reply to#16348
On Friday, 29 January 2016 20:20:38 UTC, Christoph M. Becker  wrote:

> I have no experience with the pthreads extension, but it might be
> possible to use the Threaded class[1] instead of Stackable.
> 

Hi Chris,

Threaded worked.
Thanks a lot indeed.

[toc] | [prev] | [next] | [standalone]


#16351

FromJames Wang <jwang25610@gmail.com>
Date2016-02-01 03:24 -0800
Message-ID<d24c02be-f00b-49c2-9ab1-bf48ee1910ac@googlegroups.com>
In reply to#16350
On Monday, 1 February 2016 09:29:28 UTC, James Wang  wrote:
> On Friday, 29 January 2016 20:20:38 UTC, Christoph M. Becker  wrote:
> 
> > I have no experience with the pthreads extension, but it might be
> > possible to use the Threaded class[1] instead of Stackable.
> > 
> 
> Hi Chris,
> 
> Threaded worked.
> Thanks a lot indeed.

it worked for "ordinary" data type:
<?php
class Sum extends Threaded {
    private $value = 0;
    public function add($inc)  { $this->value += $inc; }
    public function getValue() { return $this->value; }
    public function run(){}
}

class MyThread extends Thread {
    public $sum;

    public function __construct(Sum $sum) {
        $this->sum = $sum;
    }

    public function run(){
        for ($i=0; $i < 10; $i++) {
            $this->sum->add(5);
            echo $this->sum->getValue() . " ";
        }
    }
}

$sum = new Sum();
$thread = new MyThread($sum);
$thread->start();
$thread->join();
echo $sum->getValue();
?>

still does not work for array:

<?php
class Sum extends Threaded {
    private $value = array();
    public function add($inc)  {
      $this->value[] = $inc;
   }
    public function getValue() {
      return $this->value;
   }
    public function run(){}
}

class MyThread extends Thread {
    public $sum;

    public function __construct(Sum $sum) {
        $this->sum = $sum;
    }

    public function run(){
        for ($i=0; $i < 10; $i++) {
            $this->sum->add(5);
        }
echo "thread ended\n";
var_dump($this->sum->getValue());  //correct here
    }
}

$sum = new Sum();
$thread = new MyThread($sum);
$thread->start();
$thread->join();
var_dump($sum->getValue());  //null returned
?>


Please help.  Thanks a lot in advance

[toc] | [prev] | [next] | [standalone]


#16352

FromJames Wang <jwang25610@gmail.com>
Date2016-02-01 04:16 -0800
Message-ID<770974dd-5953-4304-98df-722a7deea2a4@googlegroups.com>
In reply to#16351
On Monday, 1 February 2016 11:24:47 UTC, James Wang  wrote:
> Please help.  Thanks a lot in advance

Issue resolved.  Thanks all.
Useful link:  https://github.com/krakjoe/pthreads/blob/master/examples/StackableArray.php

[toc] | [prev] | [next] | [standalone]


#16353

FromJames Wang <jwang25610@gmail.com>
Date2016-02-02 07:50 -0800
Message-ID<01598bab-98ca-49f2-b529-418791eac45c@googlegroups.com>
In reply to#16352
On Monday, 1 February 2016 12:16:28 UTC, James Wang  wrote:
> Issue resolved.  Thanks all.
> Useful link:  >https://github.com/krakjoe/pthreads/blob/master/examples/StackableArray.php

Run into trouble when I tried to pass rows=mysqli_fetch_array() from thread  to the calling function.

Array rows seams always volatile even though the the Threaded class.
 
Any one any expertise please?

Thanks a lot in advance

[toc] | [prev] | [next] | [standalone]


#16354

FromJames Wang <jwang25610@gmail.com>
Date2016-02-03 01:35 -0800
Message-ID<a1ba7737-8f03-4e2f-9549-6dd94e23d0da@googlegroups.com>
In reply to#16353
On Tuesday, 2 February 2016 15:51:11 UTC, James Wang  wrote:
> Run into trouble when I tried to pass rows=mysqli_fetch_array() from thread  to the calling function.
> Array rows seams always volatile even though the the Threaded class.
> Any one any expertise please?

passing any array object (not just mysqli_fetch_array()) fails thread:

<?php
   class myRR extends Threaded {
      public function run() {}
   }
   class C extends Thread {
      private $rr;
      public function __construct($rr) {
         $this->rr = $rr;
      }
      public function getO() { return $this->o; }
      public function run() {
         $this->rr[] = array(1,2,3,4,5);
      }
   }
   $rr = new myRR();
   $c = new C($rr);
   $c->start();
   $c->join();
   print_r($rr);
?>

i got:
pthreads detected an attempt to connect to an object which has already been destroyed in th12.php:19

Please shed some light.  Thanks a lot in advance.

[toc] | [prev] | [next] | [standalone]


#16355

FromJames Wang <jwang25610@gmail.com>
Date2016-02-03 02:12 -0800
Message-ID<b3029f58-202b-4bea-b139-f73b8afdc5e9@googlegroups.com>
In reply to#16354
On Wednesday, 3 February 2016 09:35:43 UTC, James Wang  wrote:
> passing any array object (not just mysqli_fetch_array()) fails thread:
> 
> <?php
>    class myRR extends Threaded {
>       public function run() {}
>    }
>    class C extends Thread {
>       private $rr;
>       public function __construct($rr) {
>          $this->rr = $rr;
>       }
>       public function getO() { return $this->o; }
>       public function run() {
>          $this->rr[] = array(1,2,3,4,5);
>       }
>    }
>    $rr = new myRR();
>    $c = new C($rr);
>    $c->start();
>    $c->join();
>    print_r($rr);
> ?>
> 
> i got:
> pthreads detected an attempt to connect to an object which has already been destroyed in th12.php:19
> 
> Please shed some light.  Thanks a lot in advance.

update: my colleague with php 5.6.12 (mine 7) and Zend engine 2.6 (mine 3.0) has no problem.

[toc] | [prev] | [next] | [standalone]


#16356

FromJerry Stuckle <jstucklex@attglobal.net>
Date2016-02-03 09:01 -0500
Message-ID<n8t117$q1f$1@jstuckle.eternal-september.org>
In reply to#16355
On 2/3/2016 5:12 AM, James Wang wrote:
> On Wednesday, 3 February 2016 09:35:43 UTC, James Wang  wrote:
>> passing any array object (not just mysqli_fetch_array()) fails thread:
>>
>> <?php
>>    class myRR extends Threaded {
>>       public function run() {}
>>    }
>>    class C extends Thread {
>>       private $rr;
>>       public function __construct($rr) {
>>          $this->rr = $rr;
>>       }
>>       public function getO() { return $this->o; }
>>       public function run() {
>>          $this->rr[] = array(1,2,3,4,5);
>>       }
>>    }
>>    $rr = new myRR();
>>    $c = new C($rr);
>>    $c->start();
>>    $c->join();
>>    print_r($rr);
>> ?>
>>
>> i got:
>> pthreads detected an attempt to connect to an object which has already been destroyed in th12.php:19
>>
>> Please shed some light.  Thanks a lot in advance.
> 
> update: my colleague with php 5.6.12 (mine 7) and Zend engine 2.6 (mine 3.0) has no problem.
> 

Looks like a bug, but without the documentation on the new classes yet,
it's hard to tell.  I'd suggest you file a bug and see what they say.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#16357

FromJerry Stuckle <jstucklex@attglobal.net>
Date2016-02-03 09:02 -0500
Message-ID<n8t14i$q1f$2@jstuckle.eternal-september.org>
In reply to#16355
On 2/3/2016 5:12 AM, James Wang wrote:
> On Wednesday, 3 February 2016 09:35:43 UTC, James Wang  wrote:
>> passing any array object (not just mysqli_fetch_array()) fails thread:
>>
>> <?php
>>    class myRR extends Threaded {
>>       public function run() {}
>>    }
>>    class C extends Thread {
>>       private $rr;
>>       public function __construct($rr) {
>>          $this->rr = $rr;
>>       }
>>       public function getO() { return $this->o; }
>>       public function run() {
>>          $this->rr[] = array(1,2,3,4,5);
>>       }
>>    }
>>    $rr = new myRR();
>>    $c = new C($rr);
>>    $c->start();
>>    $c->join();
>>    print_r($rr);
>> ?>
>>
>> i got:
>> pthreads detected an attempt to connect to an object which has already been destroyed in th12.php:19
>>
>> Please shed some light.  Thanks a lot in advance.
> 
> update: my colleague with php 5.6.12 (mine 7) and Zend engine 2.6 (mine 3.0) has no problem.
> 

James,

One other thought.  You mentioned you compiled PHP yourself.  Are you
sure you compiled it with zend_thread_safety enabled?  See
http://php.net/manual/en/pthreads.requirements.php.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#16358

FromJames Wang <jwang25610@gmail.com>
Date2016-02-03 06:06 -0800
Message-ID<efc19d3f-9180-4f0b-8472-88e167589f6b@googlegroups.com>
In reply to#16357
On Wednesday, 3 February 2016 14:02:43 UTC, Jerry Stuckle  wrote:
> One other thought.  You mentioned you compiled PHP yourself.  Are you
> sure you compiled it with zend_thread_safety enabled?  See
> http://php.net/manual/en/pthreads.requirements.php.

nope.

build php-5.6.17 with PECL pthreads 2 worked.  May be a bug in PECL pthreads 3 libraries 

[toc] | [prev] | [next] | [standalone]


#16359

FromJames Wang <jwang25610@gmail.com>
Date2016-02-03 06:08 -0800
Message-ID<3f6d3532-fd0c-4b98-92d7-5793c5520de4@googlegroups.com>
In reply to#16358
On Wednesday, 3 February 2016 14:07:01 UTC, James Wang  wrote:
> On Wednesday, 3 February 2016 14:02:43 UTC, Jerry Stuckle  wrote:
> > One other thought.  You mentioned you compiled PHP yourself.  Are you
> > sure you compiled it with zend_thread_safety enabled?  See
> > http://php.net/manual/en/pthreads.requirements.php.
> 
> nope.

Correction of above.
Yes, I had: ./configure --enable-maintainer-zts ...

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web