When code is executed in other vat, the runtime checks that code closes only over deep frozen or bass by copy objects. If vat is not specified, the code is scheduled to be executed at later turn in this vat. The vatHandle is an expression that evaluates to capability of executing actions on the vat.

+

When code is executed in other vat, the runtime checks that code closes only over deep frozen or pass by copy objects. If vat is not specified, the code is scheduled to be executed at later turn in this vat. The vatHandle is an expression that evaluates to capability of executing actions on the vat.

==Using==

==Using==

Revision as of 19:49, 20 November 2007

TODO possibly there should be per-operator pages.

This page describes some not implemented asynchronous control flow operators that could simplify creation of asynchronous application. The intial set of operators is based on experience of implementing the AsyncObjects framework and Sebyla project design.

Contents

Later

This is an extremely simple construct. But is useful when it is requited to execute code in this or other vat at some later time. In AsyncObjects this constructs is implemented using AsyncAction class, and it was used quite a lot in applications.

“later” ( “(” <vatHandle> “)” )? “->” “{“
<code>
“}”

When code is executed in other vat, the runtime checks that code closes only over deep frozen or pass by copy objects. If vat is not specified, the code is scheduled to be executed at later turn in this vat. The vatHandle is an expression that evaluates to capability of executing actions on the vat.

Using

This is a very simple construct that helps with resource management. The syntax is like the following:

All resources are opened in the specified order. If expression returns promise, the next expression is not executed before first one complete. If <varName> is specified for resource, the resolved resource is assigned to it and it can be used in subsequent expressions and <statements>.

If opening of some resource fails, the proposed result of operator is that failure.

Statements are executed, the proposed result of operator is value of last expression. If the result is promise, the operator waits until it is resolved.

All opened connections are closed, in reverse order. It includes connections that has not been named. If some close operations fail, the most top level one is returned.

The code in <statements-i> is executed sequentially. The next code block is executed only if promise returned from previous code block is resolved. If the block yields near value, the next block is executed on the same turn.

The result of operator is the value of the last block.

If some of blocks fails, the next blocks are not executed, and control is passed to the catch section and the result of operator will be the result of executing catch statement. If there is no catchSection, the operator fails with expression.

If there is a finally statement, it is executed after last block or after catch statement. If it fails, the entire seq expression fails with the same exception.

The semantics is the same as for normal loops. The next iteration starts only after previous completed.
TODO it might be useful to keep intermediate results of previous iteration and to make them available in the body of the loop and conditions. On other hand, it is quite easy to use basic seq operator to achieve the same result.
TODO “seq for” needs support for eventual iterators.

All

This operator allows execution of eventual expressions in parallel. The basic form is the following:

“all” “{“
<expression>
“}” ( “and” “{“
<expression>
“}” )+

The short form is the following:

“all” “(“ <expression> ( “,” <expression> )+ “)”

Semantics is the following:

All expressions starts to be executed.

If all expressions completed successfully, a list of results is returned.

If at least one expression fails, an exception that contains generated results and failures is generated.