[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] scheduling and coroutines
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] scheduling and coroutines |
Date: |
Sat, 26 Feb 2011 11:10:45 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Feb 25, 2011 at 06:06:59PM +0100, Tomtom wrote:
> Hi list.
Hi Tom!
> First of all, I'm new here and new to scheme too. So please bear with me.
Welcome. I hope you're enjoying Scheme so far :)
> it should also give a "sleep duration" after which the scheduler will have to
> resume the coroutine. That timing information would be used by the scheduler
> to
> insert the continuation at the right place in the queue.
>
> So my problem is: How can I pass the timing information from the coroutine to
> the scheduler ? I read that the procedure passed to call/cc should have only
> one argument (which will be the current continuation), but I hear rumours
> about
> those mysterious values / call-with-values procedures that have something to
> do
> with all this. Here, it starts to get blurry in my head - can anyone guide me
> further down the road ?
Yeah, you can use multiple value returns. Just change this in the scheduler:
(let ((cont (call/cc (queue-remove! q))))
...)
to this:
(let-values (((cont sleep-duration) (call/cc (queue-remove! q))))
...)
or the slightly shorter:
(receive (cont sleep-duration) (call/cc (queue-remove! q))
...)
Then when the coroutine yields to the scheduler, it can just call
cont with more than one argument.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth