blob: 69ce32aa4bef0d9ff914c8ab2c368c123c74f90f [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrab6ac9f62020-01-21 11:11:16 +01002 #include <rtlimits.h>
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstrab6ac9f62020-01-21 11:11:16 +01004 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 User88f12472016-06-24 23:31:02 +02008
Zesstra715ec202025-07-09 22:18:31 +02009DESCRIPTION
10 Call the function <fun> with any given <args> as parameters,
11 and execute it with the given runtime limits.
MG Mud User88f12472016-06-24 23:31:02 +020012
Zesstra715ec202025-07-09 22:18:31 +020013 After the function exits, the currently active limits are restored.
14 Result of the efun is the result of the closure call.
MG Mud User88f12472016-06-24 23:31:02 +020015
Zesstra715ec202025-07-09 22:18:31 +020016 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 User88f12472016-06-24 23:31:02 +020020
Zesstra715ec202025-07-09 22:18:31 +020021 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 User88f12472016-06-24 23:31:02 +020025
Zesstra715ec202025-07-09 22:18:31 +020026 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 User88f12472016-06-24 23:31:02 +020030
Zesstra715ec202025-07-09 22:18:31 +020031 The efun causes a privilege violation ("limited", current_object,
MG Mud User88f12472016-06-24 23:31:02 +020032 fun, limits-array).
33
MG Mud User88f12472016-06-24 23:31:02 +020034
Zesstra715ec202025-07-09 22:18:31 +020035EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020036 limited(#'function)
Zesstra715ec202025-07-09 22:18:31 +020037 --> executes function with no limits at all
MG Mud User88f12472016-06-24 23:31:02 +020038
39 limited(#'function, ({ 200000 }), "foo")
Zesstra715ec202025-07-09 22:18:31 +020040 --> executes function with an eval_cost limit of 200000, and
41 calls function as <function>("foo").
MG Mud User88f12472016-06-24 23:31:02 +020042
43 limited(lambda(0, ({#'function, "foo"})), LIMIT_EVAL, 200000)
Zesstra715ec202025-07-09 22:18:31 +020044 --> executes function with an eval_cost limit of 200000, and
45 calls function as <function>("foo").
MG Mud User88f12472016-06-24 23:31:02 +020046
Zesstra715ec202025-07-09 22:18:31 +020047HISTORY
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 User88f12472016-06-24 23:31:02 +020052
Zesstra715ec202025-07-09 22:18:31 +020053SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020054 query_limits(E), set_limits(E)