lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I mean I don't want to call `sleep(10)` and suddenly be suspended till 10 seconds later when the timeout occurs.  The problem with this is any function that I call could in turn call something else that implicitly suspends me.  Your wrapper is plenty explicit.

On Fri, May 11, 2012 at 12:11 PM, Jorge <> wrote:
On vie, 2012-05-11 at 09:56 -0500, Tim Caswell wrote:
> Please don't misunderstand me.
That's unavoidable, sadly :)

> My only warning is in making the suspension of the coroutine implicit.
> You can use coroutines and still be explicit about the points where
> your code can be suspended.  For example, in Luvit, I added a little
> sugar called "fiber" that looks like this:

Ok, i'm a bit lost. How does an implicit coroutine suspension look like?
My tasks can relinquish control trough a bunch of calls, easily
spottable (sched.wait, sched.signal,, and some wrappers around
those). For example I have this helper function ("run on a signal")

M.sigrun = function ( f, waitd )
       local wrapper = function()
               while true do
       return wrapper )

If the provided f doesn't explicitly yield (with a sched.signal or
something) it will run atomically. Or you mean, that I should *enforce*
that when used as this, f will not yield?