--- deliantra/server/lib/cf.pm 2007/07/23 16:53:15 1.314 +++ deliantra/server/lib/cf.pm 2007/07/23 17:53:55 1.315 @@ -324,12 +324,15 @@ $guard } -=item cf::get_slot $time[, $priority] +=item cf::get_slot $time[, $priority[, $name]] Allocate $time seconds of blocking CPU time at priority C<$priority>: This call blocks and returns only when you have at least C<$time> seconds of cpu time till the next tick. The slot is only valid till the next cede. +The optional C<$name> can be used to identify the job to run. It might be +used for statistical purposes and should identify the same time-class. + Useful for short background jobs. =cut @@ -365,10 +368,13 @@ } }; -sub get_slot($;$) { - my ($time, $pri) = @_; +sub get_slot($;$$) { + my ($time, $pri, $name) = @_; + + $time = $TICK * .6 if $time > $TICK * .6; + my $sig = new Coro::Signal; - push @SLOT_QUEUE, [$time, $pri, my $sig = new Coro::Signal]; + push @SLOT_QUEUE, [$time, $pri, $sig, $name]; @SLOT_QUEUE = sort { $b->[1] <=> $a->[1] } @SLOT_QUEUE; $SLOT_QUEUE->ready; $sig->wait;