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:
Last, even though the timer is set in milliseconds, the current implementation relies on
alarm/3, and therefore can only offer precision on the scale of seconds.
In turn, the documentation for sleep/1 states:
Block the current thread for
Timeseconds.
But the problem in this case is likely not related to the times but for the call to sleep/1 blocking the current thread where the time_out/3 call is being itself executed. Nevertheless, I tried the time_out/3 predicate with other goals and also couldn't not get the expected time out. Thus, there might be some bug in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With