Make post loop callbacks a local var so we don't have to iterate through as

much


git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@419 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2005-05-12 23:04:53 +00:00
parent 37c96a1773
commit e3a5d6c3c6

View File

@ -73,7 +73,7 @@ our (
%OtherFds, # A hash of "other" (non-Danga::Socket) file
# descriptors for the event loop to track.
$PostLoopCallback, # subref to call at the end of each loop, if defined
$LocalPostLoopCallback, # true if there is a local post loop callback in effect
%PLCMap, # fd (num) -> PostLoopCallback
);
%OtherFds = ();
@ -375,13 +375,8 @@ sub PostEventLoop {
@ToClose = ();
# now we're at the very end, call per-connection callbacks if defined
if ($LocalPostLoopCallback) {
for my $fd (%DescriptorMap) {
my $pob = $DescriptorMap{$fd};
if( defined $pob->{post_loop_callback} ) {
return unless $pob->{post_loop_callback}->(\%DescriptorMap, \%OtherFds);
}
}
for my $plc (values %PLCMap) {
return unless $plc->(\%DescriptorMap, \%OtherFds);
}
# now we're at the very end, call global callback if defined
@ -810,12 +805,10 @@ sub SetPostLoopCallback {
if(ref $class) {
my Danga::Socket $self = $class;
if( defined $ref && ref $ref eq 'CODE' ) {
$LocalPostLoopCallback++;
$self->{post_loop_callback} = $ref;
$PLCMap{$self->{fd}} = $ref;
}
else {
$LocalPostLoopCallback--;
delete $self->{post_loop_callback};
delete $PLCMap{$self->{fd}};
}
}
else {
@ -823,6 +816,11 @@ sub SetPostLoopCallback {
}
}
sub DESTROY {
my Danga::Socket $self = shift;
delete $PLCMap{$self->{fd}};
}
#####################################################################
### U T I L I T Y F U N C T I O N S
#####################################################################