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
This commit is contained in:
Ulrich Neumerkel 2009-05-19 18:10:51 +02:00 committed by Vitor Santos Costa
parent c7066b43ec
commit b38505cff2

View File

@ -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.