[erlang-questions] Is there a way to serialise a running process & resume it later (i.e. continuations)

Ivar Refsdal refsdal.ivar@REDACTED
Fri Feb 27 23:28:54 CET 2009


Correct me if I'm wrong, but take a look at this simple example:

dbl_outer(X) ->
    Y = 1234, %% impossible(?) to save variables from other outer scope, etc
    outer(X),
    io:format("dbl_outer exit...~n").

outer(X) ->
    spawn( fun() ->
              receive
              after 1000 ->
                    io:format("inner timeout.. X=~p~n", [X])
              end end),
    io:format("outer exit...~n").


My 'assumption' is that you can use funs to save local/nearest scope 
state for continuation usage, but not outer,
stack and so on. Is this a reasonable assumption or totally wrong?

Weblocks is another web framework written in Lisp using continuations 
for those interested.

Best
Ivar


Mathias Picker wrote:
> Am Donnerstag, den 26.02.2009, 21:06 -0300 schrieb Adriano Bonat:
>   
>> http://yarivsblog.com/articles/2008/02/17/seaside-style-programming-in-erlyweb/
>>     
>
> Would be nice if it were that easy. Going back a few pages breaks yaris
> solution.
>
>   
>> My "two cents" :)
>>
>> On Thu, Feb 26, 2009 at 8:51 PM, jm <jeffm@REDACTED> wrote:
>>     
>>> Robert Virding wrote:
>>>       
>>>>     To support e.g. the back-button behaviour in browsers elegantly.
>>>>     See the
>>>>     diverse seaside docs for an example how such a web framework can be
>>>>     used, and for a good explanation of why and what read "Inverting back
>>>>     the inversion of control or, continuations versus page-centric
>>>>     programming (2001)"
>>>>     http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.3112
>>>>
>>>>
>>>> Seeing the state of a process is kept explicitly in the arguments of
>>>> the functions implementing it it is easy to save the state of a
>>>> process and so step "backwards" when you want to. If you wish you can
>>>> keep a stack of process states and step backwards and forwards as you
>>>> wish. If the problem is just this then I still don't see the problem.
>>>>
>>>>         
>>> More explicitly,
>>>
>>>  * stored an id as part of the URL call it UrlId
>>>  * store contexts, {UrlId, Cxt}, as part of a list for an acceptable
>>> history range, say 10 histories per browser.
>>>     ie, [{UrlId, Cxt}, ....]
>>>
>>>  for an incoming request:
>>>     extract the id, UrlId
>>>     case proplist:lookup(UrlId, Contexts) of
>>>          none ->
>>>              %% return on error page
>>>              error_page(no_context, ....);
>>>         {UrlId, Cxt} ->
>>>              %% Found state do work
>>>               make_page(Cxt, ....)
>>>     end.
>>>
>>>
>>> Something like that should do what you wish. I've glossed over the finer
>>> points.
>>>
>>> Jeff.
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>>       
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>     
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   




More information about the erlang-questions mailing list