[ library(test_util) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]

timeout(+Goal, ++Seconds, +TimeOutGoal)

Run the goal Goal for a maximum of Seconds seconds.

Description

Goal is executed for a maximum of Seconds seconds. If the goal is still executing after Seconds, time-out occurs and the execution of the goal is terminated and TimeOutGoal is executed.

This predicate is designed to be used for testing goals which would take too long to execute within the test framework. It is based on the after event timers, so Seconds is measured in the timer currently used by after events. It can be used with other after events, although it cannot be nested with itself.

Examples

    timeout((repeat,fail), 1.5, writeln(timed-out)). % time-out from infinite loop
    

See Also

event_after / 2, get_time / 1