Catalyst::Component::ContextClosure man page on Pidora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Pidora logo
[printable version]

Catalyst::Component::CUserxContributed PCatalyst::Component::ContextClosure(3)

NAME
       Catalyst::Component::ContextClosure - Moose Role for components which
       need to close over the $ctx, without leaking

SYNOPSIS
	   package MyApp::Controller::Foo;
	   use Moose;
	   use namespace::clean -except => 'meta';
	   BEGIN {
	       extends 'Catalyst::Controller';
	       with 'Catalyst::Component::ContextClosure';
	   }

	   sub some_action : Local {
	       my ($self, $ctx) = @_;
	       $ctx->stash(a_closure => $self->make_context_closure(sub {
		   my ($ctx) = @_;
		   $ctx->response->body('body set from closure');
	       }, $ctx));
	   }

DESCRIPTION
       A common problem with stashing a closure, that closes over the Catalyst
       context (often called $ctx or $c), is the circular reference it
       creates, as the closure holds onto a reference to context, and the
       context holds a reference to the closure in its stash. This creates a
       memory leak, unless you always carefully weaken the closures context
       reference.

       This role provides a convenience method to create closures, that closes
       over $ctx.

METHODS
   make_context_closure ($closure, $ctx)
       Returns a code reference, that will invoke $closure with a weakened
       reference to $ctx. All other parameters to the returned code reference
       will be passed along to $closure.

SEE ALSO
       Catalyst::Component

       Catalyst::Controller

       CatalystX::LeakChecker

COPYRIGHT
       This library is free software. You can redistribute it and/or modify it
       under the same terms as Perl itself.

perl v5.14.2			  2012-0Catalyst::Component::ContextClosure(3)
[top]

List of man pages available for Pidora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net