… | |
… | |
118 | |
118 | |
119 | If you don't know what event loop to use, use the one returned from this |
119 | If you don't know what event loop to use, use the one returned from this |
120 | function. |
120 | function. |
121 | |
121 | |
122 | The flags argument can be used to specify special behaviour or specific |
122 | The flags argument can be used to specify special behaviour or specific |
123 | backends to use, and is usually specified as 0 (or EVFLAG_AUTO) |
123 | backends to use, and is usually specified as 0 (or EVFLAG_AUTO). |
124 | |
124 | |
125 | It supports the following flags: |
125 | It supports the following flags: |
126 | |
126 | |
127 | =over 4 |
127 | =over 4 |
128 | |
128 | |
… | |
… | |
131 | The default flags value. Use this if you have no clue (its the right |
131 | The default flags value. Use this if you have no clue (its the right |
132 | thing, believe me). |
132 | thing, believe me). |
133 | |
133 | |
134 | =item EVFLAG_NOENV |
134 | =item EVFLAG_NOENV |
135 | |
135 | |
136 | If this flag bit is ored into the flag value then libev will I<not> look |
136 | If this flag bit is ored into the flag value (or the program runs setuid |
137 | at the environment variable C<LIBEV_FLAGS>. Otherwise (the default), this |
137 | or setgid) then libev will I<not> look at the environment variable |
138 | environment variable will override the flags completely. This is useful |
138 | C<LIBEV_FLAGS>. Otherwise (the default), this environment variable will |
|
|
139 | override the flags completely if it is found in the environment. This is |
139 | to try out specific backends to tets their performance, or to work around |
140 | useful to try out specific backends to test their performance, or to work |
140 | bugs. |
141 | around bugs. |
141 | |
142 | |
142 | =item EVMETHOD_SELECT portable select backend |
143 | =item EVMETHOD_SELECT portable select backend |
143 | |
144 | |
144 | =item EVMETHOD_POLL poll backend (everywhere except windows) |
145 | =item EVMETHOD_POLL poll backend (everywhere except windows) |
145 | |
146 | |
… | |
… | |
409 | in each iteration of the event loop (This behaviour is called |
410 | in each iteration of the event loop (This behaviour is called |
410 | level-triggering because you keep receiving events as long as the |
411 | level-triggering because you keep receiving events as long as the |
411 | condition persists. Remember you cna stop the watcher if you don't want to |
412 | condition persists. Remember you cna stop the watcher if you don't want to |
412 | act on the event and neither want to receive future events). |
413 | act on the event and neither want to receive future events). |
413 | |
414 | |
|
|
415 | In general you can register as many read and/or write event watchers oer |
|
|
416 | fd as you want (as long as you don't confuse yourself). Setting all file |
|
|
417 | descriptors to non-blocking mode is also usually a good idea (but not |
|
|
418 | required if you know what you are doing). |
|
|
419 | |
|
|
420 | You have to be careful with dup'ed file descriptors, though. Some backends |
|
|
421 | (the linux epoll backend is a notable example) cannot handle dup'ed file |
|
|
422 | descriptors correctly if you register interest in two or more fds pointing |
|
|
423 | to the same file/socket etc. description. |
|
|
424 | |
|
|
425 | If you must do this, then force the use of a known-to-be-good backend |
|
|
426 | (at the time of this writing, this includes only EVMETHOD_SELECT and |
|
|
427 | EVMETHOD_POLL). |
|
|
428 | |
414 | =over 4 |
429 | =over 4 |
415 | |
430 | |
416 | =item ev_io_init (ev_io *, callback, int fd, int events) |
431 | =item ev_io_init (ev_io *, callback, int fd, int events) |
417 | |
432 | |
418 | =item ev_io_set (ev_io *, int fd, int events) |
433 | =item ev_io_set (ev_io *, int fd, int events) |