… | |
… | |
1349 | with a watcher-specific start function (\f(CW\*(C`ev_TYPE_start (loop, watcher |
1349 | with a watcher-specific start function (\f(CW\*(C`ev_TYPE_start (loop, watcher |
1350 | *)\*(C'\fR), and you can stop watching for events at any time by calling the |
1350 | *)\*(C'\fR), and you can stop watching for events at any time by calling the |
1351 | corresponding stop function (\f(CW\*(C`ev_TYPE_stop (loop, watcher *)\*(C'\fR. |
1351 | corresponding stop function (\f(CW\*(C`ev_TYPE_stop (loop, watcher *)\*(C'\fR. |
1352 | .PP |
1352 | .PP |
1353 | As long as your watcher is active (has been started but not stopped) you |
1353 | As long as your watcher is active (has been started but not stopped) you |
1354 | must not touch the values stored in it. Most specifically you must never |
1354 | must not touch the values stored in it except when explicitly documented |
1355 | reinitialise it or call its \f(CW\*(C`ev_TYPE_set\*(C'\fR macro. |
1355 | otherwise. Most specifically you must never reinitialise it or call its |
|
|
1356 | \&\f(CW\*(C`ev_TYPE_set\*(C'\fR macro. |
1356 | .PP |
1357 | .PP |
1357 | Each and every callback receives the event loop pointer as first, the |
1358 | Each and every callback receives the event loop pointer as first, the |
1358 | registered watcher structure as second, and a bitset of received events as |
1359 | registered watcher structure as second, and a bitset of received events as |
1359 | third argument. |
1360 | third argument. |
1360 | .PP |
1361 | .PP |
… | |
… | |
1953 | .PD 0 |
1954 | .PD 0 |
1954 | .IP "ev_io_set (ev_io *, int fd, int events)" 4 |
1955 | .IP "ev_io_set (ev_io *, int fd, int events)" 4 |
1955 | .IX Item "ev_io_set (ev_io *, int fd, int events)" |
1956 | .IX Item "ev_io_set (ev_io *, int fd, int events)" |
1956 | .PD |
1957 | .PD |
1957 | Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The \f(CW\*(C`fd\*(C'\fR is the file descriptor to |
1958 | Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The \f(CW\*(C`fd\*(C'\fR is the file descriptor to |
1958 | receive events for and \f(CW\*(C`events\*(C'\fR is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or |
1959 | receive events for and \f(CW\*(C`events\*(C'\fR is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR, both |
1959 | \&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR, to express the desire to receive the given events. |
1960 | \&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR or \f(CW0\fR, to express the desire to receive the given |
|
|
1961 | events. |
|
|
1962 | .Sp |
|
|
1963 | Note that setting the \f(CW\*(C`events\*(C'\fR to \f(CW0\fR and starting the watcher is |
|
|
1964 | supported, but not specially optimized \- if your program sometimes happens |
|
|
1965 | to generate this combination this is fine, but if it is easy to avoid |
|
|
1966 | starting an io watcher watching for no events you should do so. |
1960 | .IP "ev_io_modify (ev_io *, int events)" 4 |
1967 | .IP "ev_io_modify (ev_io *, int events)" 4 |
1961 | .IX Item "ev_io_modify (ev_io *, int events)" |
1968 | .IX Item "ev_io_modify (ev_io *, int events)" |
1962 | Similar to \f(CW\*(C`ev_io_set\*(C'\fR, but only changes the event mask. Using this might |
1969 | Similar to \f(CW\*(C`ev_io_set\*(C'\fR, but only changes the event mask. Using this might |
1963 | be faster with some backends, as libev can assume that the \f(CW\*(C`fd\*(C'\fR still |
1970 | be faster with some backends, as libev can assume that the \f(CW\*(C`fd\*(C'\fR still |
1964 | refers to the same underlying file description, something it cannot do |
1971 | refers to the same underlying file description, something it cannot do |
… | |
… | |
1968 | The file descriptor being watched. While it can be read at any time, you |
1975 | The file descriptor being watched. While it can be read at any time, you |
1969 | must not modify this member even when the watcher is stopped \- always use |
1976 | must not modify this member even when the watcher is stopped \- always use |
1970 | \&\f(CW\*(C`ev_io_set\*(C'\fR for that. |
1977 | \&\f(CW\*(C`ev_io_set\*(C'\fR for that. |
1971 | .IP "int events [no\-modify]" 4 |
1978 | .IP "int events [no\-modify]" 4 |
1972 | .IX Item "int events [no-modify]" |
1979 | .IX Item "int events [no-modify]" |
1973 | The set of events being watched, among other flags. This field is a |
1980 | The set of events the fd is being watched for, among other flags. Remember |
1974 | bit set \- to test for \f(CW\*(C`EV_READ\*(C'\fR, use \f(CW\*(C`w\->events & EV_READ\*(C'\fR, and |
1981 | that this is a bit set \- to test for \f(CW\*(C`EV_READ\*(C'\fR, use \f(CW\*(C`w\->events & |
1975 | similarly for \f(CW\*(C`EV_WRITE\*(C'\fR. |
1982 | EV_READ\*(C'\fR, and similarly for \f(CW\*(C`EV_WRITE\*(C'\fR. |
1976 | .Sp |
1983 | .Sp |
1977 | As with \f(CW\*(C`fd\*(C'\fR, you must not modify this member even when the watcher is |
1984 | As with \f(CW\*(C`fd\*(C'\fR, you must not modify this member even when the watcher is |
1978 | stopped, always use \f(CW\*(C`ev_io_set\*(C'\fR or \f(CW\*(C`ev_io_modify\*(C'\fR for that. |
1985 | stopped, always use \f(CW\*(C`ev_io_set\*(C'\fR or \f(CW\*(C`ev_io_modify\*(C'\fR for that. |
1979 | .PP |
1986 | .PP |
1980 | \fIExamples\fR |
1987 | \fIExamples\fR |
… | |
… | |
4411 | gets automatically stopped and restarted when reconfiguring it with this |
4418 | gets automatically stopped and restarted when reconfiguring it with this |
4412 | method. |
4419 | method. |
4413 | .Sp |
4420 | .Sp |
4414 | For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid |
4421 | For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid |
4415 | clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. |
4422 | clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. |
|
|
4423 | .Sp |
|
|
4424 | For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a |
|
|
4425 | new event mask only, and internally calls \f(CW\*(C`ev_io_modfify\*(C'\fR. |
4416 | .IP "w\->start ()" 4 |
4426 | .IP "w\->start ()" 4 |
4417 | .IX Item "w->start ()" |
4427 | .IX Item "w->start ()" |
4418 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
4428 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
4419 | constructor already stores the event loop. |
4429 | constructor already stores the event loop. |
4420 | .IP "w\->start ([arguments])" 4 |
4430 | .IP "w\->start ([arguments])" 4 |