Last active
October 26, 2015 04:09
-
-
Save holyshared/1c7468cbc319e60eae8d to your computer and use it in GitHub Desktop.
This file contains 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
This file contains 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 // 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(); | |
} |
This file contains 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 // 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