MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 2 | #include <rtlimits.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 4 | mixed limited(closure fun) |
| 5 | mixed limited(closure fun, int tag, int value, ...) |
| 6 | mixed limited(closure fun, int *limits) |
| 7 | mixed limited(closure fun, int *limits, mixed *args) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 8 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 9 | DESCRIPTION |
| 10 | Call the function <fun> with any given <args> as parameters, |
| 11 | and execute it with the given runtime limits. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 13 | After the function exits, the currently active limits are restored. |
| 14 | Result of the efun is the result of the closure call. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 16 | The runtime limits can be given in two ways: as an array (like the |
| 17 | one returned from query_limits(), or as a list of tagged values. If |
| 18 | the efun is used without any limit specification, all limits are |
| 19 | supposed to be 'unlimited'. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 20 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 21 | The limit settings recognize three special values: |
| 22 | LIMIT_UNLIMITED: the limit is deactivated |
| 23 | LIMIT_KEEP: the former setting is kept |
| 24 | LIMIT_DEFAULT: the 'global' default setting is used. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 25 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 26 | For LIMIT_COST, the special values have these meaning: |
| 27 | LIMIT_UNLIMITED: at maximum 1 tick is accounted |
| 28 | LIMIT_KEEP: LIMIT_COST is set to 0 |
| 29 | LIMIT_DEFAULT: LIMIT_COST is set to -100 |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 31 | The efun causes a privilege violation ("limited", current_object, |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 32 | fun, limits-array). |
| 33 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 34 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 35 | EXAMPLES |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 36 | limited(#'function) |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 37 | --> executes function with no limits at all |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 38 | |
| 39 | limited(#'function, ({ 200000 }), "foo") |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 40 | --> executes function with an eval_cost limit of 200000, and |
| 41 | calls function as <function>("foo"). |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 42 | |
| 43 | limited(lambda(0, ({#'function, "foo"})), LIMIT_EVAL, 200000) |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 44 | --> executes function with an eval_cost limit of 200000, and |
| 45 | calls function as <function>("foo"). |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 46 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 47 | HISTORY |
| 48 | Introduced in LDMud 3.2.7. |
| 49 | LDMud 3.3.563 introduced LIMIT_COST. |
| 50 | LDMud 3.3.677 introduced LIMIT_MAPPING_KEYS, LIMIT_MAPPING_SIZE. |
| 51 | LDMud 3.5.0 introduced LIMIT_MEMORY. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 52 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 53 | SEE ALSO |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 54 | query_limits(E), set_limits(E) |