[Catalyst] Catalyst::Component/Model Instances and Attributes per Request

Alejandro Imass alejandro.imass at gmail.com
Sun Jul 18 18:23:22 GMT 2010


On Sun, Jul 18, 2010 at 12:29 PM, Tomas Doran <bobtfish at bobtfish.net> wrote:
>
> On 17 Jul 2010, at 18:58, Alejandro Imass wrote:
>>
>> I am confused now. mod_worker will share the same code segment for
>> sure, and if you said earlier that in some scenarios where the code
>> segment is shared (i.e. two _threads_ using the same model instance)
>> the ACCEPT_CONTEXT call will override any global variables (i.e. Moose
>> object parameters) that were set by the previous the ACCEPT_CONTEXT
>> call. Or I understood wrong....
>
> Perl code isn't in the 'code segment' of your process.
>
> As it's compiled and run dynamically, after all. :)
>
> So only the perl executable and C shared libraries (.sos) will be in code
> segments. All of your perl code is in data segments.
>

Yes, this is true, just a manner of trying to explain myself about the
separation of variables and code. Nevertheless, the thread
implementation does somthing like this when mounting a module via use.
I am almost sure but will look for references on this on a mod_perl
book.

>> I'm pretty sure there is no sequential guarantee (a queue/stack) when
>> two controller threads use the same model instance, nor is the thread
>> implementation aware that it should create a separate data segment for
>> the second and beyond calls to ACCEPT_CONTEXT.
>
> No, hang on.. This works using perl's threads, so be default you have
> 'nothing shared'..
>
> I may be entirely wrong here (someone correct me?)

I think you are correct sir. Nothing is shared by default in Perl
threads, and only simple structures can be shared using
threads::shared - anyway all this confusion I've created is about
running Catalyst using mod_perl/mod_worker. Let me see if I can the
references and post them here. But after some thought, and without
knowing _exactly_ how it works, much like astrophysicists can
speculate about the cat and mouse in the tube, each process or thread
(it makes no real difference IMHO) will have it's own copy of every
object, from the controller to the model. I think that's what you've
been trying to tell me all along, but I still get weary about the
"instance" bit. Guess I'll have too look a bit under the hood for this
one....






>
> Cheers
> t0m
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list