# Handling

## Functions

int | ppl_set_timeout (unsigned time)
| Sets the timeout for computations whose completion could require an exponential amount of time.
int | ppl_reset_timeout (void)
| Resets the timeout time so that the computation is not interrupted.
int | ppl_set_deterministic_timeout (unsigned weight)
| Sets a threshold for computations whose completion could require an exponential amount of time.
int | ppl_reset_deterministic_timeout (void)
| Resets the deterministic timeout so that the computation is not interrupted.

## Detailed Description

Functions for setting and resetting timeouts.

## Function Documentation

int ppl_set_timeout | ( | unsigned | time | ) |

Sets the timeout for computations whose completion could require an exponential amount of time.

Parameters:

  | time | The number of hundreths of seconds. It must be strictly greater than zero.

Computations taking exponential time will be interrupted some time after `time` hundreths of seconds have elapsed since the call to the timeout setting function. If the computation is interrupted that way, the interrupted function will return error code `PPL_TIMEOUT_EXCEPTION`. Otherwise, if the computation completes without being interrupted, then the timeout should be reset by calling `ppl_reset_timeout()`.

int ppl_set_deterministic_timeout | ( | unsigned | weight | ) |

Sets a threshold for computations whose completion could require an exponential amount of time.

Parameters:

  | weight | The maximum computational weight allowed. It must be strictly greater than zero.

Computations taking exponential time will be interrupted some time after reaching the `weight` complexity threshold. If the computation is interrupted that way, the interrupted function will return error code `PPL_TIMEOUT_EXCEPTION`. Otherwise, if the computation completes without being interrupted, then the deterministic timeout should be reset by calling `ppl_reset_deterministic_timeout()`.

Note:
  This "timeout" checking functionality is said to be deterministic because it is not based on actual elapsed time. Its behavior will only depend on (some of the) computations performed in the PPL library and it will be otherwise independent from the computation environment (CPU, operating system, compiler, etc.).

Warning:
  The weight mechanism is under alpha testing. In particular, there is still no clear relation between the weight threshold and the actual computational complexity. As a consequence, client applications should be ready to reconsider the tuning of these weight thresholds when upgrading to newer version of the PPL.