Skip to content

Instantly share code, notes, and snippets.

@derickr
Created November 23, 2022 00:33
Show Gist options
  • Save derickr/2068a0f8998bfea849867f3234dda811 to your computer and use it in GitHub Desktop.
Save derickr/2068a0f8998bfea849867f3234dda811 to your computer and use it in GitHub Desktop.
workers.php
<?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