jastrachan | 29 Apr 09:45 2004

Re: [groovy-dev] Re: Generators take 2 (was [groovy-dev] Generator Expressions)

On 28 Apr 2004, at 16:36, Paulo Gaspar wrote:
> Hi James,
>> If so we could maybe assume that only 1 generator will be in use by 1
> thread at once and use a static ThreadLocal to maintain the ...
> That is nasty. A practical code example I have that would break if I
> converted it from Java to "yelded"
> Groovy is some recursive stuff I have to handle nested ResultSets 
> (which
> I often used in the past with
> Oracle databases). AND I believe that code would be more readable if I
> converted it.


> However, it would fairly simple to hold a stack of stacks on a
> ThreadLocal, i.e.: a stack with the state
> of the generators being processed, each of the entries holding the 
> state
> (stack) of each generator.
> =:o)

Yes - I think turning methods with yield statements into Iterator 
objects seems the cleanest approach - then they work in multiple 
threads & handle recursion neatly.