lua-users home
lua-l archive

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


On Wed, 2006-01-25 at 22:10 -0500, Jon Smirl wrote:
> I'm evaluating doing some programming in lua and I've been reading
> through coroutine support and things like Copas.
> 
> Lately I've been working with Ruby. Ruby definitely has a superior
> solution to the blocking IO problem.  In lua you need to do
> copas.receive(skt). This will cause the coroutines to schedule. In
> Ruby you just do receive(skt) without needing the copas wrapper. This
> is because the Ruby library converts what looks like synchronous IO
> into asynchronous IO internally. Internally Ruby will do an async read
> from the socket and if nothing is available it will schedule it's
> threads. They have pushed the copas functionality down into the base
> language library.  Ruby does this for all things that can block, not
> just the network.
> 
> Has a change like this been considered for lua? I find the Ruby
> solution much easier to work with.
> 
> --
> Jon Smirl
> jonsmirl@gmail.com

Have a look at the way the Xavante server implemented in Lua at
keplerproject.org uses copas.  IIRC, you can create a copas socket that
wraps a luaSocket, but has the same interface (at least the same
interface needed after you wrap it).

If Copas doesn't actually do this, it would be extremely easy to add it
in.
-- 


JJS
"If Ignorance is Bliss, I'll take the Pain."