Re: Howto use pause and resume with latest IO

petri rokka <[email protected]>
Newsgroups gmane.comp.lang.io
Message-ID <[email protected]>
I fail to see why application should always exit when yieldingCoros empties.
It is a normal state because yieldingCoros is empty when i start io
interpreter.

I need to pause the last coro to give back control to the C++ app that
called the io evaluation function. Io is running in a separate thread in the
C++ app, but it needs to do c++ stuff to communicate with other threads.

I made overloaded implementation of pause that does not exit when
yieldingCoros empties and it seems to work fine.

How can i get the currentCoro If I try-catch exception inside actor method.

actor doSomething := method(
    e := try(
                actor realCoro := ????
        doFile("test_that_yields_many_times.io")
    )
)

...
actor doSomething
...
actor pause
...
actor realCoro resume
...



2011/5/23 Jan-Paul Bultmann <[email protected]>

>
>
>
> On May 18, 2011, at 3:58 PM, petri rokka wrote:
>
>
>
> Great that you found a fix :) . Can you post the fix here so i can try it
> out. Should my posted test app work with it?
>
> Btw. I am also having problem with pause. I need to pause/resume  the only
> existing coro in application to pause it and continue it later (io is
> embedded in my c++ app) , but its impossible because pause forces
> application system exit at that point. :/
>
> Could you make different pause that doesn't force the system exit?
>
>
> Hey sorry I write that late, but I was on the Typo Berlin, so not much net
> and even less time.
>
> I don't think that what you want to do is possible with coroutines.
> The reason is that when pause is called, the coroutine wont actually pause.
> Instead another coroutine will resume, taking care of replacing and thus
> stopping the currently running.
> I would instead recommend to run the embedded VM in it's own thread and
> pause it externally, or use the thread Addon, though I don't know how to use
> that.
>
> Hope it helps.
> Cheers Jan
>
> 2011/5/17 Jan-Paul Bultmann <[email protected]>
>
>>
>>
>>
>> On May 17, 2011, at 8:50 PM, Steve Dekorte wrote:
>>
>>
>>
>>
>> On 2011-05-17 Tue, at 06:34 AM, Jan-Paul Bultmann wrote:
>> > Why is a new coroutine generated anyways? And especially where? I would
>> consider it unwanted behavior if you resume one Coroutine but your stuff
>> will run in another.
>>
>> There are a few cases:
>> 1) when you do a try() - exceptions handling is implemented with coros.
>> 2) when a coro gets close to running out of stack space, it creates a new
>> coro to continue executing in.
>>
>> Cool to know, thanks :)
>>
>>
>> It's surprising this hasn't come up before, but your code exposes a bug in
>> the current actor implementation. I'll add a bit of code to Coroutine to
>> make sure resumes are sent to the proper child coroutine.
>>
>> - Steve
>>
>>
>>
>>
>
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.