cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: Problem with JPetStore
Date Wed, 19 Mar 2003 21:55:48 GMT
Christopher Oliver wrote:

> Sylvain Wallez wrote:
>
>> Christopher Oliver wrote:
>>
>>> Sylvain Wallez wrote:
>>>
>>>> Moreover, AFAIU, the "productList" variable in viewCategory() is 
>>>> stored in the continuation, and so if we hit "next" and then 
>>>> "prev", the first list exists twice (in different continuations). 
>>>> Isn't there a potential memory consumption problem ? I know 
>>>> continuations expire, but withing the expiration delay, all these 
>>>> lists keep floating around...
>>>
>>>
>>> Yes, but the only things that are really duplicated are the program 
>>> counter and stack frames, and even the stack itself is lazily 
>>> copied. The local variables themselves (like productList) are shared 
>>> between continuations.
>>
>>
>> What do you mean by "lazily copied" ? Doesn't it need to be actually 
>> copied to be stored ?
>
>
> What I mean is if you have a call chain:
>
> function f() {
>    g();
> }
>
> function g() {
>    h();
> }
>
> function h() {
>    while (true) {
>       sendPage(...);
>    }
> }
>
> The call frames that represent the calls to f() and g() are shared 
> between all continuations captured inside h(). But when a continuation 
> escapes the while loop and returns to g(), then, at that point, a copy 
> of the call frame of g() is made, and so on as you return up the stack. 


Ah, I understand : common stack frames are shared between continuations 
having the same ancestor continuations.

>> Also, how can local variables be shared between continuations if 
>> their value changes between calls to sendPageAndWait, as is the case 
>> of producList ? Isn't it contradictory with the continuation concept 
>> which should restore variable values ?
>
>
> No. That's the intended behavior - just like in Scheme. Invoking a 
> continuation only restores the program counter. It does not roll back 
> changes to other data. That behavior would be way too expensive! As it 
> is the cost of invoking a continuation is negligable.


Mmmmh... I guess what you mean here is that the PC and the stack frame 
are restored, which also includes local variables. What isn't restored 
is the state of objects pointed by these local variables.

Does JavaScript, like Java, make a difference between primitive types 
(stored by value on the stack) and object types (stored by reference) ? 
My understanding after some tests is that a difference is made.

>> Sorry for these newbie questions. Is there any docs that explains all 
>> this ? If found your post about JavaScript for Java programmers but 
>> it doesn't give any details about this.
>
>
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102781075226697&w=2


Wikified at 
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations !!

Thanks,
Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



Mime
View raw message