… | |
… | |
75 | can use it through the AnyEvent module, stay portable to other event |
75 | can use it through the AnyEvent module, stay portable to other event |
76 | loops (if you don't rely on any watcher types not available through it) |
76 | loops (if you don't rely on any watcher types not available through it) |
77 | and still be faster than with any other event loop currently supported |
77 | and still be faster than with any other event loop currently supported |
78 | in Perl. |
78 | in Perl. |
79 | |
79 | |
|
|
80 | PORTING FROM EV 3.X to 4.X |
|
|
81 | EV version 4 introduces a number of incompatible changes summarised |
|
|
82 | here. According to the depreciation strategy used by libev, there is a |
|
|
83 | compatibility layer in place so programs should continue to run |
|
|
84 | unchanged (the XS interface lacks this layer, so programs using that one |
|
|
85 | need to be updated). |
|
|
86 | |
|
|
87 | This compatibility layer will be switched off in some future release. |
|
|
88 | |
|
|
89 | All changes relevant to Perl are renames of symbols, functions and |
|
|
90 | methods: |
|
|
91 | |
|
|
92 | EV::loop => EV::run |
|
|
93 | EV::LOOP_NONBLOCK => EV::RUN_NOWAIT |
|
|
94 | EV::LOOP_ONESHOT => EV::RUN_ONCE |
|
|
95 | |
|
|
96 | EV::unloop => EV::break |
|
|
97 | EV::UNLOOP_CANCEL => EV::BREAK_CANCEL |
|
|
98 | EV::UNLOOP_ONE => EV::BREAK_ONE |
|
|
99 | EV::UNLOOP_ALL => EV::BREAK_ALL |
|
|
100 | |
|
|
101 | EV::TIMEOUT => EV::TIMER |
|
|
102 | |
|
|
103 | EV::loop_count => EV::iteration |
|
|
104 | EV::loop_depth => EV::depth |
|
|
105 | EV::loop_verify => EV::verify |
|
|
106 | |
|
|
107 | The loop object methods corresponding to the functions above have been |
|
|
108 | similarly renamed. |
|
|
109 | |
80 | MODULE EXPORTS |
110 | MODULE EXPORTS |
81 | This module does not export any symbols. |
111 | This module does not export any symbols. |
82 | |
112 | |
83 | EVENT LOOPS |
113 | EVENT LOOPS |
84 | EV supports multiple event loops: There is a single "default event loop" |
114 | EV supports multiple event loops: There is a single "default event loop" |
… | |
… | |
766 | $w = $loop->check_ns ($callback) |
796 | $w = $loop->check_ns ($callback) |
767 | Call the callback just after the process wakes up again (after it |
797 | Call the callback just after the process wakes up again (after it |
768 | has gathered events), but before any other callbacks have been |
798 | has gathered events), but before any other callbacks have been |
769 | invoked. |
799 | invoked. |
770 | |
800 | |
771 | This is used to integrate other event-based software into the EV |
801 | This can be used to integrate other event-based software into the EV |
772 | mainloop: You register a prepare callback and in there, you create |
802 | mainloop: You register a prepare callback and in there, you create |
773 | io and timer watchers as required by the other software. Here is a |
803 | io and timer watchers as required by the other software. Here is a |
774 | real-world example of integrating Net::SNMP (with some details left |
804 | real-world example of integrating Net::SNMP (with some details left |
775 | out): |
805 | out): |
776 | |
806 | |
… | |
… | |
812 | watchers are destroyed before this can happen (remember EV::check |
842 | watchers are destroyed before this can happen (remember EV::check |
813 | gets called first). |
843 | gets called first). |
814 | |
844 | |
815 | The "check_ns" variant doesn't start (activate) the newly created |
845 | The "check_ns" variant doesn't start (activate) the newly created |
816 | watcher. |
846 | watcher. |
|
|
847 | |
|
|
848 | EV::CHECK constant issues |
|
|
849 | Like all other watcher types, there is a bitmask constant for use in |
|
|
850 | $revents and other places. The "EV::CHECK" is special as it has the |
|
|
851 | same name as the "CHECK" sub called by Perl. This doesn't cause big |
|
|
852 | issues on newer perls (beginning with 5.8.9), but it means thatthe |
|
|
853 | constant must be *inlined*, i.e. runtime calls will not work. That |
|
|
854 | means that as long as you always "use EV" and then "EV::CHECK" you |
|
|
855 | are on the safe side. |
817 | |
856 | |
818 | FORK WATCHERS - the audacity to resume the event loop after a fork |
857 | FORK WATCHERS - the audacity to resume the event loop after a fork |
819 | Fork watchers are called when a "fork ()" was detected. The invocation |
858 | Fork watchers are called when a "fork ()" was detected. The invocation |
820 | is done before the event loop blocks next and before "check" watchers |
859 | is done before the event loop blocks next and before "check" watchers |
821 | are being called, and only in the child after the fork. |
860 | are being called, and only in the child after the fork. |