Re: Failing on event occurence

From: Kish Shen <>
Date: Fri 02 Nov 2001 05:40:45 PM GMT
Message-Id: <>
>I need some help on the following issue. I have a piece of code like:

>  set_event_handler(too_long, stop_execution/0),
>  event_after(too_long, 100),
>  compute,
>  cancel_after_event(too_long).

I assume you defined stop_execution/0 to fail, and this did not cause
compute/0 to fail? The manual probably should be clearer, but any failures
inside the after event handler goal is not propagated. This allows all
pending after events to be handled.

In order to cause a failure in the `outer' computation, the handler should
not fail directly, but set up and trigger another goal that is executed
which does cause the failure. The simplest way to do this is to wrap your
compute/0 in a block/3:

  start :-
        set_event_handler(too_long, exit_block/1),
        event_after(too_long, 100),
        block(compute, too_long, fail),

Note that if compute/0 fails on its own, the after event is not turned
off. For a more elaborate example, take a look at the timeout/4 example at
the end of the Events and Interrupts chapter of the User Manual.


Kish Shen
Received on Fri Nov 02 17:41:14 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:11 PM GMT GMT