ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.3
(Generate patch)

Comparing libev/ev.3 (file contents):
Revision 1.48 by root, Sun Dec 9 19:47:29 2007 UTC vs.
Revision 1.49 by root, Wed Dec 12 04:53:58 2007 UTC

127.\} 127.\}
128.rm #[ #] #H #V #F C 128.rm #[ #] #H #V #F C
129.\" ======================================================================== 129.\" ========================================================================
130.\" 130.\"
131.IX Title ""<STANDARD INPUT>" 1" 131.IX Title ""<STANDARD INPUT>" 1"
132.TH "<STANDARD INPUT>" 1 "2007-12-09" "perl v5.8.8" "User Contributed Perl Documentation" 132.TH "<STANDARD INPUT>" 1 "2007-12-12" "perl v5.8.8" "User Contributed Perl Documentation"
133.SH "NAME" 133.SH "NAME"
134libev \- a high performance full\-featured event loop written in C 134libev \- a high performance full\-featured event loop written in C
135.SH "SYNOPSIS" 135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS" 136.IX Header "SYNOPSIS"
137.Vb 1 137.Vb 1
1065If you cannot run the fd in non-blocking mode (for example you should not 1065If you cannot run the fd in non-blocking mode (for example you should not
1066play around with an Xlib connection), then you have to seperately re-test 1066play around with an Xlib connection), then you have to seperately re-test
1067whether a file descriptor is really ready with a known-to-be good interface 1067whether a file descriptor is really ready with a known-to-be good interface
1068such as poll (fortunately in our Xlib example, Xlib already does this on 1068such as poll (fortunately in our Xlib example, Xlib already does this on
1069its own, so its quite safe to use). 1069its own, so its quite safe to use).
1070.PP
1071\fIThe special problem of disappearing file descriptors\fR
1072.IX Subsection "The special problem of disappearing file descriptors"
1073.PP
1074Some backends (e.g kqueue, epoll) need to be told about closing a file
1075descriptor (either by calling \f(CW\*(C`close\*(C'\fR explicitly or by any other means,
1076such as \f(CW\*(C`dup\*(C'\fR). The reason is that you register interest in some file
1077descriptor, but when it goes away, the operating system will silently drop
1078this interest. If another file descriptor with the same number then is
1079registered with libev, there is no efficient way to see that this is, in
1080fact, a different file descriptor.
1081.PP
1082To avoid having to explicitly tell libev about such cases, libev follows
1083the following policy: Each time \f(CW\*(C`ev_io_set\*(C'\fR is being called, libev
1084will assume that this is potentially a new file descriptor, otherwise
1085it is assumed that the file descriptor stays the same. That means that
1086you \fIhave\fR to call \f(CW\*(C`ev_io_set\*(C'\fR (or \f(CW\*(C`ev_io_init\*(C'\fR) when you change the
1087descriptor even if the file descriptor number itself did not change.
1088.PP
1089This is how one would do it normally anyway, the important point is that
1090the libev application should not optimise around libev but should leave
1091optimisations to libev.
1070.IP "ev_io_init (ev_io *, callback, int fd, int events)" 4 1092.IP "ev_io_init (ev_io *, callback, int fd, int events)" 4
1071.IX Item "ev_io_init (ev_io *, callback, int fd, int events)" 1093.IX Item "ev_io_init (ev_io *, callback, int fd, int events)"
1072.PD 0 1094.PD 0
1073.IP "ev_io_set (ev_io *, int fd, int events)" 4 1095.IP "ev_io_set (ev_io *, int fd, int events)" 4
1074.IX Item "ev_io_set (ev_io *, int fd, int events)" 1096.IX Item "ev_io_set (ev_io *, int fd, int events)"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines