-
-
Save proudlygeek/9738711 to your computer and use it in GitHub Desktop.
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
<?hh | |
async function helloAfter($name, $timeout) { | |
// sleep asynchronously -- let other async functions do their job | |
await SleepWaitHandle::create($timeout * 1000000); | |
echo sprintf("hello %s\n", $name); | |
} | |
async function run() { | |
$joe = helloAfter('Joe', 3); | |
$mike = helloAfter('Mike', 1); | |
// wait for both dependencies | |
await GenArrayWaitHandle::create(array($joe, $mike)); | |
} | |
run()->join(); | |
// prints: | |
// hello Mike | |
// hello Joe | |
//The example is based on the discussion provided here: https://github.com/facebook/hhvm/issues/1494 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment