blob: d72999d2645f8de4cb73cf630f25014ef6f71dc8 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
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
11DESCRIPTION
Zesstra7ea4a032019-11-26 20:11:40 +010012 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 User88f12472016-06-24 23:31:02 +020014
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
Zesstra7ea4a032019-11-26 20:11:40 +010039 returns 0, no further attempt to clean up this object will be made.
MG Mud User88f12472016-06-24 23:31:02 +020040
41HISTORY
42
43SEE ALSO
44 hooks(C)