From f9533c875764a810c456c562d461e38ea351388a Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 21 May 2009 01:30:24 -0500 Subject: [PATCH] fix backtracking in timeout. --- library/timeout.yap | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index d276ba923..6981b4239 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -44,12 +44,24 @@ run_goal(Goal, Result0) :- % we can only enable interrupts after alarm was been enabled. yap_hacks:enable_interrupts, Result0 = success, + yap_hacks:current_choice_point(CP0), call(Goal), - !, + yap_hacks:current_choice_point(CP1), % make sure we're not getting an extraneous interrupt if we terminate early.... - yap_hacks:disable_interrupts, - alarm(0,_,_), - true. + alarm(0,_,RT), + ( + CP0 == CP1 + -> + true + ; + ( + true + ; + alarm(RT,throw(time_out),_), + fail + ) + ). + run_goal(Goal, Result0) :- yap_hacks:disable_interrupts, % make sure we're not getting an extraneous interrupt if we terminate early....