workers.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Calculator | |
{ | |
private int $lastResult; | |
static private function fib(int $n) : int | |
{ | |
if ($n <= 1) { | |
return 1; | |
} | |
return self::fib($n - 1) + self::fib($n - 2); | |
} | |
public function process(int $n) : void | |
{ | |
xdebug_connect_to_client(); | |
$this->lastResult = self::fib($n); | |
// xdebug_notify($this); | |
} | |
} | |
// Main Loop | |
$calculator = new Calculator; | |
for ($i = 0; $i < 500; $i++) | |
{ | |
$calculator->process( $i % 10 ); | |
echo $i, " "; | |
sleep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment