lua-users home
lua-l archive

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

> Being able to block at scope exit (in Lua, from a "__close" metamethod hand
> control back to the coroutine scheduler via "yield") is fundamental to
> implementing structured concurrency.
> Would there be any way to lift this restriction from the to-be-closed
> implementation?

I don't see any conceptual problem, but I don't have a clear idea of how
hard it would be to implement it.

It seems that we could add a bit in callstatus that we are running a
"__close" metamethod and then allow yields. In case of yield, after
finishing the function, 'unroll' have to check that bit and, if true,
continue the interrupted work (remove the upvalue from the list and
run the other pending closes).

All very slippery code :-)

-- Roberto