On 2006-07-02, Jeremy Tregunna <jtregunna
blurgle.ca> wrote:
> Your code is in need of some work (or at least, how I would have
> written it). Here's my version (works as expected with latest Io):
>
> // clip here ---
> generator := Object clone do(
> newSlot("value")
> newSlot("input")
> newSlot("coro")
> newSlot("waitingCoro")
>
> run := method(
> coro = coroDo(
> pause
> 0 to(1000) foreach(i,
> setValue(i + input)
> waitingCoro resume
> )
> )
> )
>
> next := method(v,
> setInput(v)
> setWaitingCoro(Coroutine currentCoro)
> coro resume
> value
> )
> )
>
> generator run
> generator next(10) println
> generator next(100) println
> generator next(1000) println
>
> // clip here ---
Thanks, very nice!
> If you have any problems, or questions; let me know.
Yes, I have both. Let's start with the most weird of them:
The code works as expected with the io binary, but gets blocked
before anything could happen if I'm using ioServer.
I compiled these binaries from yesterday's code, on FreeBSD 6.0.
Regards,
Csaba