[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: implementing a future in lua
- From: "李慧霸" <magazine.lihuiba@...>
- Date: Fri, 2 Jan 2009 11:08:35 +0800
Sorry to reply so late. I don't have freqent Internet access.
As what VSP said, it is used for Asynchronious communcations, without
callbacks however. In my opinion, the term "concurrency" here doesn't
involve any parallelism, or so-called "true concurrency". So what I'm
using is coroutine.
Alex mentioned using metamethods (thanks for your adivce). But I have
encountered a problem with this approach: yielding across them. Suppose
we have a function like:
If we pass a undeterin future variable to this function, the expression
a+b would have to yield to wait for the future's determination. Yielding
across metamethods seem not to be supported. In contrast, lanes doesn't
need to yield, they just block to wait for results from other preemptive
I want future to be as transparent as possible, existing modules (at least
lua code) that doesn't take future into account should work properly with
it. So I'm reading and modifying the source code of lua. But the biggest
problem I think is yielding. Transparent future may yield everywhere, but
current VM implementation doesn't allow this. Maybe coco is the solution.