Did you know ... Search Documentation:
Pack resbound -- README

Resource bounded goals

This pack provides library(resource_bounds), which allows running a goal providing limits for the wall time, CPU time and stack usage.

Examples

?- resource_bounded_call(true, 1, Status, []).
Status = true.
?- resource_bounded_call(fail, 1, Status, []).
Status = false.
?- resource_bounded_call((repeat, fail), 0.001, Status, []).
Status = timeout(cpu).
?- resource_bounded_call(sleep(20), 0.001, Status, [wall_time(1)]).
Status = timeout(wall).
?- resource_bounded_call(numlist(1, 1000000, L), 1, Status, [global(1000)]).
Status = stack_overflow(global).