… | |
… | |
1124 | is that you cannot use blocking APIs, but the non-blocking variant should |
1124 | is that you cannot use blocking APIs, but the non-blocking variant should |
1125 | work. |
1125 | work. |
1126 | |
1126 | |
1127 | =cut |
1127 | =cut |
1128 | |
1128 | |
1129 | our $VERSION = '3.4'; |
1129 | our $VERSION = '5.23'; |
1130 | |
1130 | |
1131 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1131 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1132 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1132 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1133 | |
1133 | |
1134 | sub timer { |
1134 | sub timer { |
… | |
… | |
1136 | |
1136 | |
1137 | my $cb = $arg{cb}; |
1137 | my $cb = $arg{cb}; |
1138 | |
1138 | |
1139 | urxvt::timer |
1139 | urxvt::timer |
1140 | ->new |
1140 | ->new |
1141 | ->after ($arg{after}) |
1141 | ->after ($arg{after}, $arg{interval}) |
1142 | ->interval ($arg{interval}) |
1142 | ->cb ($arg{interval} ? $cb : sub { |
1143 | ->start |
|
|
1144 | ->cb (sub { |
|
|
1145 | #TODO interval? |
|
|
1146 | $_[0]->stop; # need to cancel manually |
1143 | $_[0]->stop; # need to cancel manually |
1147 | $cb->(); |
1144 | $cb->(); |
1148 | }) |
1145 | }) |
1149 | } |
1146 | } |
1150 | |
1147 | |
… | |
… | |
1171 | my $cb = $arg{cb}; |
1168 | my $cb = $arg{cb}; |
1172 | |
1169 | |
1173 | urxvt::iw |
1170 | urxvt::iw |
1174 | ->new |
1171 | ->new |
1175 | ->start |
1172 | ->start |
1176 | ->cb (sub { |
1173 | ->cb ($cb) |
1177 | #TODO really cancel? |
|
|
1178 | $_[0]->stop; # need to cancel manually |
|
|
1179 | $cb->(); |
|
|
1180 | }) |
|
|
1181 | } |
1174 | } |
1182 | |
1175 | |
1183 | sub child { |
1176 | sub child { |
1184 | my ($class, %arg) = @_; |
1177 | my ($class, %arg) = @_; |
1185 | |
1178 | |
… | |
… | |
1187 | |
1180 | |
1188 | urxvt::pw |
1181 | urxvt::pw |
1189 | ->new |
1182 | ->new |
1190 | ->start ($arg{pid}) |
1183 | ->start ($arg{pid}) |
1191 | ->cb (sub { |
1184 | ->cb (sub { |
1192 | #TODO really cancel? |
|
|
1193 | $_[0]->stop; # need to cancel manually |
1185 | $_[0]->stop; # need to cancel manually |
1194 | $cb->($_[0]->rpid, $_[0]->rstatus); |
1186 | $cb->($_[0]->rpid, $_[0]->rstatus); |
1195 | }) |
1187 | }) |
1196 | } |
1188 | } |
1197 | |
1189 | |
… | |
… | |
2061 | |
2053 | |
2062 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
2054 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
2063 | |
2055 | |
2064 | Set the callback to be called when the timer triggers. |
2056 | Set the callback to be called when the timer triggers. |
2065 | |
2057 | |
2066 | =item $tstamp = $timer->at |
|
|
2067 | |
|
|
2068 | Return the time this watcher will fire next. |
|
|
2069 | |
|
|
2070 | =item $timer = $timer->set ($tstamp) |
2058 | =item $timer = $timer->set ($tstamp[, $interval]) |
2071 | |
2059 | |
2072 | Set the time the event is generated to $tstamp. |
2060 | Set the time the event is generated to $tstamp (and optionally specifies a |
|
|
2061 | new $interval). |
2073 | |
2062 | |
2074 | =item $timer = $timer->interval ($interval) |
2063 | =item $timer = $timer->interval ($interval) |
2075 | |
2064 | |
2076 | Normally (and when C<$interval> is C<0>), the timer will automatically |
2065 | By default (and when C<$interval> is C<0>), the timer will automatically |
2077 | stop after it has fired once. If C<$interval> is non-zero, then the timer |
2066 | stop after it has fired once. If C<$interval> is non-zero, then the timer |
2078 | is automatically rescheduled at the given intervals. |
2067 | is automatically rescheduled at the given intervals. |
2079 | |
2068 | |
2080 | =item $timer = $timer->start |
2069 | =item $timer = $timer->start |
2081 | |
2070 | |
2082 | Start the timer. |
2071 | Start the timer. |
2083 | |
2072 | |
2084 | =item $timer = $timer->start ($tstamp) |
2073 | =item $timer = $timer->start ($tstamp[, $interval]) |
2085 | |
2074 | |
2086 | Set the event trigger time to C<$tstamp> and start the timer. |
2075 | Set the event trigger time to C<$tstamp> and start the timer. Optionally |
|
|
2076 | also replaces the interval. |
2087 | |
2077 | |
2088 | =item $timer = $timer->after ($delay) |
2078 | =item $timer = $timer->after ($delay[, $interval]) |
2089 | |
2079 | |
2090 | Like C<start>, but sets the expiry timer to c<urxvt::NOW + $delay>. |
2080 | Like C<start>, but sets the expiry timer to c<urxvt::NOW + $delay>. |
2091 | |
2081 | |
2092 | =item $timer = $timer->stop |
2082 | =item $timer = $timer->stop |
2093 | |
2083 | |