def main(p) do
p
|> Task.async()
|> Task.await()
end
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
p(ctx)
Thread p = new Thread(() -> {});
p.start();
p.join(5_000);
p.interrupt();
var
P: TProcess;
begin
...
P.Execute;
if not P.WaitOnExit(5000) then P.Terminate(0);
end.
my $p = Coro->new( sub { ... } );
$p->ready;
my $start = time;
for (1..100) {
cede;
if ( (time - $start) > 5 ) {
$p->cancel;
last;
}
}
Timeout::timeout(5) { p }
timeout(Duration::from_secs(5), p()).await;