On Thu, 29 Jan 2009, David Ihnen wrote:
>
> I have encountered this 'back call into execution context' a few times.
> Generally to me this means you have a singleton pattern.
>
> In a short concise code expression:
>
> package Cart;
> my $instance;
> sub new { return $instance ||= bless {}, $self }
> sub is_in_cart { ... }
>
> package Catalog;
> sub show_flag {
>    my $self = shift;
>    Cart->new->is_in_cart(shift);
> }
>
> The function new on Cart returns any already created instance if it exists and
> creates a new one if not.
> The package Catalog merely calls Cart->new when it wants a Cart, without
> having to worry about whether or not there is an instance of it yet or not
> (Cart class's problem) - since the same instance is returned on every call to
> new, that makes the Cart a singleton.  It can be accessed from anywhere in the
> interpreter that has access to the Cart namespace by a static call to
> Cart->new

Under mod_perl, doesn't that mean that if user A is the
first to hit an interpreter and the cart instance is created
for them, then if user B's request is the next to be served
by the mod_perl child, that user B will get user A's cart?

Mark

Reply via email to