In SPIN events can be dispatched asynchronously to detach execution of callees from the execution of the caller either for performance or safety reasons. For instance, networking code can pass a packet to an untrusted extension from interrupt level if it is guaranteed that control comes back to it fast enough. One way of achieving it is to spawn an asynchronous thread for that handler; in SPIN this can be done transparently by making an event asynchronous. An asynchronous event raise creates a thread that synchronously dispatches the invocation to all the handlers.
Sometimes it is advantageous to be able to execute asynchronously only some handlers. For example, if a file system is extended with lazy replication then the original code should perform the write synchronously but the replication can be done asynchronously. SPIN allows making handlers asynchronous. When an event raised and a handler installed on this event is asynchronous handler then, if the guards for the handler evaluate to TRUE , a thread is created to execute that handler.
PROCEDURE SetAsynchronousEvent (event : PROCANY;
asynchronous : BOOLEAN;
module: RTCode.Module)
RAISES { Error };
PROCEDURE SetAsynchronousHandler (binding: Binding;
asynchronous : BOOLEAN)
RAISES { Error };
Przemek Pardyak,