Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created April 1, 2024 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james2doyle/f8cd45eba8328f077c9ae2e3f8c1a8c9 to your computer and use it in GitHub Desktop.
Save james2doyle/f8cd45eba8328f077c9ae2e3f8c1a8c9 to your computer and use it in GitHub Desktop.
An example of parallel which is a parallel concurrency extension for PHP
<?php
/** @see https://www.php.net/manual/en/intro.parallel.php */
$runtime = new \parallel\Runtime();
$channel = new \parallel\Channel();
// Run a task in parallel, passing a channel for communication
$future = $runtime->run(function () use ($channel) {
// Do some work here
$channel->send('Result');
}, $channel);
// Get the result from the channel
$result = $channel->recv();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment