Acme-Parataxis
view release on metacpan or search on metacpan
eg/tui_bubbletea.pl view on Meta::CPAN
my $model = {
cursor => 0,
ticks => 0,
toggled => {},
width => $init_w,
height => $init_h,
items => [
'Async I/O via thread pool',
'Fibers with cooperative scheduling',
'Nonblocking reads on STDIN',
'Concurrent tick timers',
'Channel-based message passing',
'SIGWINCH resize support',
'No Term::ReadKey dependency'
],
};
# Spawn concurrent fibers (use `fiber` -- it has the & prototype)
fiber { input_fiber( $messages, $quit ) };
fiber { tick_fiber( $messages, $quit ) };
fiber { resize_fiber( $messages, $quit, $init_w, $init_h ) };
t/029_saturation.t view on Meta::CPAN
$fills++;
}
is $fills, MAX_JOBS, 'job pool: filled all 1024 slots' or diag "filled only $fills (submission returned $rc)";
my $full = Acme::Parataxis::submit_c_job( 0, 300, 0 );
ok $full < 0, "job pool: next submission refused when full (got $full)";
Acme::Parataxis->yield while outstanding() > 0;
is Acme::Parataxis::submit_c_job( 0, 1, 0 ), 0, 'job pool: submission succeeds after the pool drained';
};
ok outstanding() == 0, 'job pool: nothing left outstanding after the pool drain';
# Park 1023 fibers on a signal (no sleep jobs, no timers) to fill the 1024-slot fiber table alongside the running main
# fiber; the next spawn must croak.
async {
my $sig = Acme::Parataxis::Signal->new;
my $waiters = 0;
my $full_err;
for ( 1 .. MAX_FIBERS + 2 ) {
my $ok = eval {
fiber { $sig->wait };
1;
};
( run in 1.786 second using v1.01-cache-2.11-cpan-e7c6538aa59 )