ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro.pm
(Generate patch)

Comparing Coro/Coro.pm (file contents):
Revision 1.129 by root, Wed Sep 19 22:33:08 2007 UTC vs.
Revision 1.130 by root, Thu Sep 20 12:02:25 2007 UTC

230terminate }> once per second or so to slowly replenish the pool. 230terminate }> once per second or so to slowly replenish the pool.
231 231
232=cut 232=cut
233 233
234our $POOL_SIZE = 8; 234our $POOL_SIZE = 8;
235our $MAX_POOL_RSS = 64 * 1024;
235our @pool; 236our @pool;
236 237
237sub pool_handler { 238sub pool_handler {
238 while () { 239 while () {
239 $current->{desc} = "[async_pool]"; 240 $current->{desc} = "[async_pool]";
242 my ($cb, @arg) = @{ delete $current->{_invoke} or return }; 243 my ($cb, @arg) = @{ delete $current->{_invoke} or return };
243 $cb->(@arg); 244 $cb->(@arg);
244 }; 245 };
245 warn $@ if $@; 246 warn $@ if $@;
246 247
247 last if @pool >= $POOL_SIZE; 248 last if @pool >= $POOL_SIZE || $current->rss >= $MAX_POOL_RSS;
248 249
249 push @pool, $current; 250 push @pool, $current;
250 $current->{desc} = "[async_pool idle]"; 251 $current->{desc} = "[async_pool idle]";
251 $current->save (Coro::State::SAVE_DEF); 252 $current->save (Coro::State::SAVE_DEF);
252 $current->prio (0); 253 $current->prio (0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines