Skip to content

Instantly share code, notes, and snippets.

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 robertlemmen/56ff110b3c57b3368064e4098bc9129e to your computer and use it in GitHub Desktop.
Save robertlemmen/56ff110b3c57b3368064e4098bc9129e to your computer and use it in GitHub Desktop.
async concurrency
my $done = Promise.new();
my $listener = IO::Socket::Async.listen('127.0.0.1', 8080);
my $tap = $listener.tap( -> $client {
say "acepted on " ~ $*THREAD.id;
$client.Supply().tap(-> $input {
say "read input on " ~ $*THREAD.id;
$client.print($input);
sleep-until now+10;
say "/read $*THREAD.id;
});
});
await $done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment