Did you know ... Search Documentation:
Pack resbound -- prolog/resource_bounds.pl
PublicShow source

This library allows running a goal, providing limits for the wall time, CPU time and stack usage.

See also
- call_with_time_limit/2
- call_with_depth_limit/3
 resource_bounded_call(:Goal, +MaxCPU, -Status, +Options) is det
Run Goal in a guarded environment, limiting its resources. Note that resource_bounded_call/4 does not guard against mallicious behaviour of Goal!

If all solutions of Goal are needed, Goal must be wrapped in findall/3.

Below are some 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).
Goal- is the goal to execute
MaxCPU- is the maximum CPU time to use
Status- is unified with the status. It is either one of the values returned by thread_join/2 or one of
Goal was aborted due to exceeded CPU Time
Goal was aborted due to exceeded Wall Time
Goal terminated due to a global stack overflow
Goal terminated due to a local stack overflow
Options- processed
Max local stack usage in cells. Note that the actual stack limits are rounded up to the nearest power of two.
Max global stack usage in cells. The value is rounded as local(KCells).
In limit the wall time in addition to the CPU time.