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 |
| 12 | Optional hook to clean up an object. |
| 13 | Hook setting can be any closure, or the name of the function |
| 14 | to call in the object. |
| 15 | |
| 16 | This hook is called for an object if it hasn't been used |
| 17 | for at least TIME_TO_CLEAN_UP seconds, to give it the |
| 18 | opportunity to self destruct. |
| 19 | |
| 20 | If the hook is a closure, it is called with the refcount of |
| 21 | the object to clean up as first argument, and with the object |
| 22 | itself as second. Lambda closures are also bound to the object |
| 23 | prior to the call. |
| 24 | |
| 25 | If the hook is the name of an lfun, it is called in the |
| 26 | object with its refcount as argument. |
| 27 | |
| 28 | In both calls, the refcount is constructed as: |
| 29 | |
| 30 | ref = 0: the object is a clone, or a blueprint with |
| 31 | replaced program. |
| 32 | ref = 1: the object is a swapped or unused blueprint. |
| 33 | ref > 1: the object is a used blueprint with <ref> references. |
| 34 | |
| 35 | The cleanup method has the possibility to destruct the |
| 36 | object. To survive this time, but try again some time later, |
| 37 | the call has to result in a non-zero value. |
| 38 | |
| 39 | If the hook specifies a non-existing lfun, or if the call |
| 40 | returns 0, no further attempt to clean up this object will be done. |
| 41 | |
| 42 | HISTORY |
| 43 | |
| 44 | SEE ALSO |
| 45 | hooks(C) |