OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [CrtChnlHdlr.3] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1996 Sun Microsystems, Inc.
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" RCS: @(#) $Id: CrtChnlHdlr.3,v 1.1.1.1 2002-01-16 10:25:23 markom Exp $
8
.so man.macros
9
.TH Tcl_CreateChannelHandler 3 7.5 Tcl "Tcl Library Procedures"
10
.BS
11
'\" Note:  do not modify the .SH NAME line immediately below!
12
.SH NAME
13
Tcl_CreateChannelHandler, Tcl_DeleteChannelHandler \- call a procedure when a channel becomes readable or writable
14
.SH SYNOPSIS
15
.nf
16
.nf
17
\fB#include \fR
18
.sp
19
void
20
\fBTcl_CreateChannelHandler\fR(\fIchannel, mask, proc, clientData\fR)
21
.sp
22
void
23
\fBTcl_DeleteChannelHandler\fR(\fIchannel, proc, clientData\fR)
24
.sp
25
.SH ARGUMENTS
26
.AS Tcl_ChannelProc clientData
27
.AP Tcl_Channel channel in
28
Tcl channel such as returned by \fBTcl_CreateChannel\fR.
29
.AP int mask in
30
Conditions under which \fIproc\fR should be called: OR-ed combination of
31
\fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR. Specify
32
a zero value to temporarily disable an existing handler.
33
.AP Tcl_FileProc *proc in
34
Procedure to invoke whenever the channel indicated by \fIchannel\fR meets
35
the conditions specified by \fImask\fR.
36
.AP ClientData clientData in
37
Arbitrary one-word value to pass to \fIproc\fR.
38
.BE
39
 
40
.SH DESCRIPTION
41
.PP
42
\fBTcl_CreateChannelHandler\fR arranges for \fIproc\fR to be called in the
43
future whenever input or output becomes possible on the channel identified
44
by \fIchannel\fR, or whenever an exceptional condition exists for
45
\fIchannel\fR. The conditions of interest under which \fIproc\fR will be
46
invoked are specified by the \fImask\fR argument.
47
See the manual entry for \fBfileevent\fR for a precise description of
48
what it means for a channel to be readable or writable.
49
\fIProc\fR must conform to the following prototype:
50
.CS
51
typedef void Tcl_ChannelProc(
52
        ClientData \fIclientData\fR,
53
        int \fImask\fR);
54
.CE
55
.PP
56
The \fIclientData\fR argument is the same as the value passed to
57
\fBTcl_CreateChannelHandler\fR when the handler was created. Typically,
58
\fIclientData\fR points to a data structure containing application-specific
59
information about the channel. \fIMask\fR is an integer mask indicating
60
which of the requested conditions actually exists for the channel; it will
61
contain a subset of the bits from the \fImask\fR argument to
62
\fBTcl_CreateChannelHandler\fR when the handler was created.
63
.PP
64
Each channel handler is identified by a unique combination of \fIchannel\fR,
65
\fIproc\fR and \fIclientData\fR.
66
There may be many handlers for a given channel as long as they don't
67
have the same \fIchannel\fR, \fIproc\fR, and \fIclientData\fR.
68
If \fBTcl_CreateChannelHandler\fR is invoked when there is already a handler
69
for \fIchannel\fR, \fIproc\fR, and \fIclientData\fR, then no new
70
handler is created;  instead, the \fImask\fR is changed for the
71
existing handler.
72
.PP
73
\fBTcl_DeleteChannelHandler\fR deletes a channel handler identified by
74
\fIchannel\fR, \fIproc\fR and \fIclientData\fR; if no such handler exists,
75
the call has no effect.
76
.PP
77
Channel handlers are invoked via the Tcl event mechanism, so they
78
are only useful in applications that are event-driven.
79
Note also that the conditions specified in the \fImask\fR argument
80
to \fIproc\fR may no longer exist when \fIproc\fR is invoked:  for
81
example, if there are two handlers for \fBTCL_READABLE\fR on the same
82
channel, the first handler could consume all of the available input
83
so that the channel is no longer readable when the second handler
84
is invoked.
85
For this reason it may be useful to use nonblocking I/O on channels
86
for which there are event handlers.
87
 
88
.SH "SEE ALSO"
89
Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n).
90
 
91
.SH KEYWORDS
92
blocking, callback, channel, events, handler, nonblocking.

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.