ASP4::Mock::Pool - Mimics the $r->pool APR::Pool object


ASP4 documentation Contained in the ASP4 distribution.

Index


Code Index:

NAME

Top

ASP4::Mock::Pool - Mimics the $r->pool APR::Pool object

SYNOPSIS

Top

  my $pool = $r->pool;
  $pool->cleanup_register( sub { ... }, \@args );

DESCRIPTION

Top

This package mimics the APR::Pool object obtained via $r->pool in a normal mod_perl2 environment.

PUBLIC METHODS

Top

cleanup_register( sub { ... }, \@args )

Causes the subref to be executed with \@args at the end of the current request.

BUGS

Top

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4 to submit bug reports.

HOMEPAGE

Top

Please visit the ASP4 homepage at http://0x31337.org/code/ to see examples of ASP4 in action.


ASP4 documentation Contained in the ASP4 distribution.

package ASP4::Mock::Pool;

use strict;
use warnings 'all';

sub new { return bless { cleanup_handlers => [ ] }, shift }
sub call_cleanup_handlers {
  my $s = shift;
  map { $_->( ) } @{ $s->{cleanup_handlers} }
}
sub cleanup_register {
  my ($s, $handler, $args) = @_;
  
  push @{ $s->{cleanup_handlers} }, sub { $handler->( $args ) };
}

sub DESTROY
{
  my $s = shift;
  undef(%$s);
}# end DESTROY()

1;# return true: