MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
| 2 | #include <sys/driver_hooks.h> |
| 3 | |
| 4 | set_driver_hook(H_CLEAN_UP, value) |
| 5 | |
| 6 | <value> being: |
| 7 | |
| 8 | int <closure>(int ref, object ob) |
| 9 | void|int <name>(int ref) |
| 10 | |
| 11 | DESCRIPTION |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 12 | Optional hook to clean up an object. Hook setting can be any |
| 13 | closure, or the name of the function to call in the object. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 14 | |
| 15 | This hook is called for an object if it hasn't been used |
| 16 | for at least TIME_TO_CLEAN_UP seconds, to give it the |
| 17 | opportunity to self destruct. |
| 18 | |
| 19 | If the hook is a closure, it is called with the refcount of |
| 20 | the object to clean up as first argument, and with the object |
| 21 | itself as second. Lambda closures are also bound to the object |
| 22 | prior to the call. |
| 23 | |
| 24 | If the hook is the name of an lfun, it is called in the |
| 25 | object with its refcount as argument. |
| 26 | |
| 27 | In both calls, the refcount is constructed as: |
| 28 | |
| 29 | ref = 0: the object is a clone, or a blueprint with |
| 30 | replaced program. |
| 31 | ref = 1: the object is a swapped or unused blueprint. |
| 32 | ref > 1: the object is a used blueprint with <ref> references. |
| 33 | |
| 34 | The cleanup method has the possibility to destruct the |
| 35 | object. To survive this time, but try again some time later, |
| 36 | the call has to result in a non-zero value. |
| 37 | |
| 38 | If the hook specifies a non-existing lfun, or if the call |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 39 | returns 0, no further attempt to clean up this object will be made. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 40 | |
| 41 | HISTORY |
| 42 | |
| 43 | SEE ALSO |
| 44 | hooks(C) |