Skip to content

Commit

Permalink
Add new test file for supply syntax non-blocking.
Browse files Browse the repository at this point in the history
We'll flesh out the semantics of `await` inside of a `supply`,
`react`, and `whenever` block a little later on. For now, this just
ensures that `react` itself is non-blocking.
  • Loading branch information
jnthn committed Jan 27, 2017
1 parent 44ba5ec commit 8dead1c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions S17-supply/syntax-nonblocking-await.t
@@ -0,0 +1,32 @@
use v6.d.PREVIEW;
use Test;

plan 1;

{
# Start 100 workers that do a `react`. This will, if `react` blocks,
# clog up the thread pool.
my $sup = Supplier.new;
my $c = Channel.new;
for ^100 {
start {
react {
whenever $sup {
$c.send($_);
done;
}
$c.send("started");
}
}
}

# Ensure they're all started.
$c.receive xx 100;

# Start one more worker that will provide a value for all of the
# reacts. If the thread pool is clogged, it won't get to run.
await start { $sup.emit(2) }

# Should now get all values sent.
is [+](($c.receive xx 100)), 200, 'start react { ... } is non-blocking';
}

0 comments on commit 8dead1c

Please sign in to comment.