Skip to content

Commit

Permalink
Merge pull request joewalnes#340 from azjezz/patch-2
Browse files Browse the repository at this point in the history
[hack example] use `HH\Asio\usleep()` instead of `usleep`
  • Loading branch information
asergeyev authored Jan 29, 2019
2 parents 5c11ca2 + 3c92490 commit b75996b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions examples/hack/count.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use namespace HH\Lib\Str;
use function HH\Lib\Experimental\IO\request_output;
use function usleep;

// Simple example script that counts to 10 at ~2Hz, then stops.

Expand All @@ -14,13 +13,12 @@ async function count_to_ten(): Awaitable<noreturn> {
await $output->writeAsync(
Str\format("%d\n",$count)
);

// usleep is builtin, it is not an async builtin - so it also must block the main request thread
usleep(500000);

HH\Asio\usleep(500000);
}

// flush output
await $output->flushAsync();

exit(0);
}

0 comments on commit b75996b

Please sign in to comment.