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:
parent
c7066b43ec
commit
b38505cff2
@ -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.
|
||||
|
Reference in New Issue
Block a user