From b38505cff25b873c3870669c02695632125e692a Mon Sep 17 00:00:00 2001 From: Ulrich Neumerkel Date: Tue, 19 May 2009 18:10:51 +0200 Subject: [PATCH] FIXED: time_out output argument, exceptions (unhappy about once) ?- time_out(true,3600,time_out). yes ?- catch(time_out(throw(x),3600,R),x,length(L,L)). ERROR!! UNHANDLED EXCEPTION - message time_out unknown --- library/timeout.yap | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index 1ed0bf0f5..607e73f20 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -30,14 +30,9 @@ time_out(Goal, Time, Result) :- % enable alarm alarm(T.UT,throw(time_out),_), % launch goal and wait for signal - ( catch(Goal, time_out, Result = time_out) - % make sure to disable alarm - -> - alarm(0,_,_) - ; - alarm(0,_,_), - fail - ), - % just couldn't resist... - (Result = success -> true ; true). - + call_cleanup( + catch( ( Result0 = success, once(Goal) ), + time_out, + Result0 = time_out ), + alarm(0,_,_) ), + Result = Result0.