… | |
… | |
3391 | Associates a different C<struct ev_loop> with this watcher. You can only |
3391 | Associates a different C<struct ev_loop> with this watcher. You can only |
3392 | do this when the watcher is inactive (and not pending either). |
3392 | do this when the watcher is inactive (and not pending either). |
3393 | |
3393 | |
3394 | =item w->set ([arguments]) |
3394 | =item w->set ([arguments]) |
3395 | |
3395 | |
3396 | Basically the same as C<ev_TYPE_set>, with the same arguments. Must be |
3396 | Basically the same as C<ev_TYPE_set>, with the same arguments. Either this |
3397 | called at least once. Unlike the C counterpart, an active watcher gets |
3397 | method or a suitable start method must be called at least once. Unlike the |
3398 | automatically stopped and restarted when reconfiguring it with this |
3398 | C counterpart, an active watcher gets automatically stopped and restarted |
3399 | method. |
3399 | when reconfiguring it with this method. |
3400 | |
3400 | |
3401 | =item w->start () |
3401 | =item w->start () |
3402 | |
3402 | |
3403 | Starts the watcher. Note that there is no C<loop> argument, as the |
3403 | Starts the watcher. Note that there is no C<loop> argument, as the |
3404 | constructor already stores the event loop. |
3404 | constructor already stores the event loop. |
3405 | |
3405 | |
|
|
3406 | =item w->start ([arguments]) |
|
|
3407 | |
|
|
3408 | Instead of calling C<set> and C<start> methods separately, it is often |
|
|
3409 | convenient to wrap them in one call. Uses the same type of arguments as |
|
|
3410 | the configure C<set> method of the watcher. |
|
|
3411 | |
3406 | =item w->stop () |
3412 | =item w->stop () |
3407 | |
3413 | |
3408 | Stops the watcher if it is active. Again, no C<loop> argument. |
3414 | Stops the watcher if it is active. Again, no C<loop> argument. |
3409 | |
3415 | |
3410 | =item w->again () (C<ev::timer>, C<ev::periodic> only) |
3416 | =item w->again () (C<ev::timer>, C<ev::periodic> only) |
… | |
… | |
3422 | |
3428 | |
3423 | =back |
3429 | =back |
3424 | |
3430 | |
3425 | =back |
3431 | =back |
3426 | |
3432 | |
3427 | Example: Define a class with an IO and idle watcher, start one of them in |
3433 | Example: Define a class with two I/O and idle watchers, start the I/O |
3428 | the constructor. |
3434 | watchers in the constructor. |
3429 | |
3435 | |
3430 | class myclass |
3436 | class myclass |
3431 | { |
3437 | { |
3432 | ev::io io ; void io_cb (ev::io &w, int revents); |
3438 | ev::io io ; void io_cb (ev::io &w, int revents); |
|
|
3439 | ev::io2 io2 ; void io2_cb (ev::io &w, int revents); |
3433 | ev::idle idle; void idle_cb (ev::idle &w, int revents); |
3440 | ev::idle idle; void idle_cb (ev::idle &w, int revents); |
3434 | |
3441 | |
3435 | myclass (int fd) |
3442 | myclass (int fd) |
3436 | { |
3443 | { |
3437 | io .set <myclass, &myclass::io_cb > (this); |
3444 | io .set <myclass, &myclass::io_cb > (this); |
|
|
3445 | io2 .set <myclass, &myclass::io2_cb > (this); |
3438 | idle.set <myclass, &myclass::idle_cb> (this); |
3446 | idle.set <myclass, &myclass::idle_cb> (this); |
3439 | |
3447 | |
3440 | io.start (fd, ev::READ); |
3448 | io.set (fd, ev::WRITE); // configure the watcher |
|
|
3449 | io.start (); // start it whenever convenient |
|
|
3450 | |
|
|
3451 | io2.start (fd, ev::READ); // set + start in one call |
3441 | } |
3452 | } |
3442 | }; |
3453 | }; |
3443 | |
3454 | |
3444 | |
3455 | |
3445 | =head1 OTHER LANGUAGE BINDINGS |
3456 | =head1 OTHER LANGUAGE BINDINGS |