Can anyone explain why the following YAP code does not result in the variable Result being unified with time_out?
?- time_out(sleep(3),1,Result).
Result = success.
?- time_out(sleep(3),2,Result).
Result = success.
?- time_out(sleep(3),1000,Result).
Result = success.
?- time_out(sleep(3),2000,Result).
According to the documentation, the predicate should work as follows:
time_out(+Goal, +Timeout, -Result)Execute goal
Goalwith time limitedTimeout, whereTimeoutis measured in milliseconds. If the goal succeeds, unifyResultwithsuccess. If the timer expires before the goal terminates, unifyResultwithtime_out.
YAP's documentation also states that:
In turn, the documentation for
sleep/1states:But the problem in this case is likely not related to the times but for the call to
sleep/1blocking the current thread where thetime_out/3call is being itself executed. Nevertheless, I tried thetime_out/3predicate with other goals and also couldn't not get the expected time out. Thus, there might be some bug in it.