Created
November 23, 2022 00:33
-
-
Save derickr/2068a0f8998bfea849867f3234dda811 to your computer and use it in GitHub Desktop.
workers.php
This file contains hidden or 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