Debian Codegraph @

doc/CallDel.3

raw
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH Tcl_CallWhenDeleted 3 7.0 Tcl "Tcl Library Procedures"
9 .so man.macros
10 .BS
11 .SH NAME
12 Tcl_CallWhenDeleted, Tcl_DontCallWhenDeleted \- Arrange for callback when interpreter is deleted
13 .SH SYNOPSIS
14 .nf
15 \fB#include <tcl.h>\fR
16 .sp
17 \fBTcl_CallWhenDeleted\fR(\fIinterp\fR, \fIproc\fR, \fIclientData\fR)
18 .sp
19 \fBTcl_DontCallWhenDeleted\fR(\fIinterp\fR, \fIproc\fR, \fIclientData\fR)
20 .SH ARGUMENTS
21 .AS Tcl_InterpDeleteProc clientData
22 .AP Tcl_Interp *interp in
23 Interpreter with which to associated callback.
24 .AP Tcl_InterpDeleteProc *proc in
25 Procedure to call when \fIinterp\fR is deleted.
26 .AP ClientData clientData in
27 Arbitrary one-word value to pass to \fIproc\fR.
28 .BE
29 .SH DESCRIPTION
30 .PP
31 \fBTcl_CallWhenDeleted\fR arranges for \fIproc\fR to be called by
32 \fBTcl_DeleteInterp\fR if/when \fIinterp\fR is deleted at some future
33 time. \fIProc\fR will be invoked just before the interpreter
34 is deleted, but the interpreter will still be valid at the
35 time of the call.
36 \fIProc\fR should have arguments and result that match the
37 type \fBTcl_InterpDeleteProc\fR:
38 .PP
39 .CS
40 typedef void \fBTcl_InterpDeleteProc\fR(
41 ClientData \fIclientData\fR,
42 Tcl_Interp *\fIinterp\fR);
43 .CE
44 .PP
45 The \fIclientData\fR and \fIinterp\fR parameters are
46 copies of the \fIclientData\fR and \fIinterp\fR arguments given
47 to \fBTcl_CallWhenDeleted\fR.
48 Typically, \fIclientData\fR points to an application-specific
49 data structure that \fIproc\fR uses to perform cleanup when an
50 interpreter is about to go away.
51 \fIProc\fR does not return a value.
52 .PP
53 \fBTcl_DontCallWhenDeleted\fR cancels a previous call to
54 \fBTcl_CallWhenDeleted\fR with the same arguments, so that
55 \fIproc\fR will not be called after all when \fIinterp\fR is
56 deleted.
57 If there is no deletion callback that matches \fIinterp\fR,
58 \fIproc\fR, and \fIclientData\fR then the call to
59 \fBTcl_DontCallWhenDeleted\fR has no effect.
60 .PP
61 Note that if the callback is being used to delete a resource that \fImust\fR
62 be released on exit, \fBTcl_CreateExitHandler\fR should be used to ensure that
63 a callback is received even if the application terminates without deleting the interpreter.
64 .SH "SEE ALSO"
65 Tcl_CreateExitHandler(3), Tcl_CreateThreadExitHandler(3)
66 .SH KEYWORDS
67 callback, cleanup, delete, interpreter