Raku Books / Perl 6 at a Glance / New Concepts / Promises

in and at

The other two factory methods, Promise.in and Promise.at, create a promise, which will be kept after a given number of seconds or by a given time. For example:

my $p = Promise.in(3);

for 1..5 {
    say $p.status;
    sleep 1;
}

🧵 This program uses concurrency (promises, threads). The in-browser engine (Raku.js) is single-threaded and can’t run it yet — try it on your own computer.

CodeBlockPlaceholder2 Planned Planned Planned Kept Kept ```

That means that the promise was kept after three seconds.

Course navigation

start   |   anyof and allof