Skip to content

Instantly share code, notes, and snippets.

@holyshared
Last active October 26, 2015 04:09
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 holyshared/1c7468cbc319e60eae8d to your computer and use it in GitHub Desktop.
Save holyshared/1c7468cbc319e60eae8d to your computer and use it in GitHub Desktop.
<?hh // strict
namespace async;
async function a() : Awaitable<string>
{
await SleepWaitHandle::create(2000);
echo 'a', PHP_EOL;
return 'a';
}
async function b() : Awaitable<string>
{
await SleepWaitHandle::create(1000);
echo 'b', PHP_EOL;
return 'b';
}
function main() : array<string>
{
$handles = GenArrayWaitHandle::create([
a(),
b()
]);
return $handles->join();
}
<?hh // partial
namespace async;
require_once __DIR__ . '/async.hh';
$res = main();
var_dump($res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment