coroutines bug?

View: New views
2 Messages — Rating Filter:   Alert me  

coroutines bug?

by Bugzilla from saintiss@gmx.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I have the following small program using coroutines:



cnt := Object clone
cnt N := 0
cnt inc := method("incing!" println; N = N + 1)
cnt read := method("reading!" println; N)

incrementor := Object clone
incrementor run := method("running!" println; cnt @inc; yield)

"all created" println

r1 := cnt @read
incrementor @run
yield
r2 := cnt @read
yield
incrementor clone @run
yield
r3 := cnt @read

"at the end" println
r1 println
r2 println
r3 println

"really at the end" println





Strangely, I get the following output (consistently):

all created
running!
reading!
incing!
running!
reading!
at the end
0
1
incing!
reading!
2
really at the end
really at the end



So the question is: How is it possible that "really at the end" is output
twice?

I'm running Io on Linux btw...

Thanks in advance,

Hans


--
Dr. Hans Schippers
Doctor-Assistant
Formal Techniques in Software Engineering (FoTS)
University of Antwerp
Middelheimlaan 1
2020 Antwerpen - Belgium
Phone: +32 3 265 37 88
Fax: +32 3 265 37 77
http://www.win.ua.ac.be/~hschipp/

A liberal is a person whose interests aren't at stake at the moment
 -- Willis Player

Re: coroutines bug?

by Steve Dekorte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-04-21, at 2:54 AM, Hans Schippers wrote:
> I have the following small program using coroutines:


Hi Hans,

Thanks for the bug report. I can repeat the bug. It looks like an  
issue with Futures (not coroutines in general). I'm guessing a Future  
resumes the wrong coro. The web of futures dependencies is somewhat  
complex - I'll try to make a simpler test when time permits.

- Steve