cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <res1c...@verizon.net>
Subject Re: Problem with JPetStore
Date Wed, 19 Mar 2003 18:39:39 GMT
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.

> 
> 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.

> 
> 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

> 
> Also, how are handled global variables ? AFAIU calling createSession() 
> "attaches" them to the session, but what if createSession() isn't called ?
> 
Then a new fresh set are created each time.

> And what is the relationship between global variables and continuations ?
> 

No special relationship: global variables are accessible in 
continuations as are local variables.


Mime
View raw message