You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
<?php
require 'vendor/autoload.php';
class DeferredWorker extends Thread
{
protected $deferred = null;
public $promise = null;
public function __construct() {
$this->deferred = new React\Promise\Deferred();
$this->promise = $this->deferred->promise();
}
}
class Worker1 extends DeferredWorker
{
public function run() {
sleep(1);
$this->deferred->resolve("worker 1");
}
}
$w1 = new Worker1();
$w1->promise->then(function ($value) {
echo $value; // not called, yet no ERROR
});
$w1->start();
The code seems normal to me; think it's a straight forward way to do async tasks in javascript. I'm wondering what I'm missing to do promises properly in PHP with pThread?
Thanks,
Shawn
The text was updated successfully, but these errors were encountered:
Using this promise library with composer
Test code
The code seems normal to me; think it's a straight forward way to do async tasks in javascript. I'm wondering what I'm missing to do promises properly in PHP with pThread?
Thanks,
Shawn
The text was updated successfully, but these errors were encountered: