previous | top | next
Advanced structured concurrency: "@" ("Alt") operator
Expr1 @ Expr2 @ ... @ ExprN
- Executes expressions 1..N in parallel.
- As soon as one of the expressions finishes evaluating, its
result is returned and the other pending expressions are
cancelled.
- Idea of 'structured concurrency' borrowed from Austin University's Orc language.
- Most obvious use is for exploring alternatives:
function get_cnn_feed() { ... }
function get_bbc_feed() { ... }
function send_mail() { ... }
send_mail(get_cnn_feed() @ get_bbc_feed(),
"alex@croczilla.com");
- But ... many concurrency problems fit into this pattern.
- Useful for implementing timeouts, user cancellation,
reliability, ...
High-level concurrency for JS - http://www.croczilla.com/stratified