Generator ?

This topic contains 5 replies, has 4 voices, and was last updated by  Samah 2 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #2274


    I’ve seen mention of <span class=”crayon-v”>Generator</span><span class=”crayon-e “><T>, which from the snippets I can find looks like a nice way of doing sequence generation and iteration, but I can’t find the class in the current code base.</span>

    Is <span class=”crayon-v”>Generator</span><span class=”crayon-e “><T></span> going to come back at some point?



    Mark covered implementing Generators using Fibers and gives a few examples in his Feb 1st “Fun with fibers” blog post on the main page.  It has all the info you need to make your own generators



    Aha! Great! Thanks  🙂



    Played with the fiber/generator stuff a bit yesterday – seems like a nice generalised way to do coroutine/state-machine type designs – good stuff  🙂

    (I’m a C# dev by trade and I love all this stuff: async/await, coroutines/yield etc. can lead to some lovely designs)

    Anyone know if there are any plans to add threading in the future?

    Always seems a shame when you have 2/4/6/8 cores but can only use 1 of them.

    (again, I love C#’s Task Parallel Library – makes it really simple to make use of multiple cores)


    Mark Sibly

    Yeah, the fiber stuff is pretty cool – especially now with the low-level fiber switch asm code from boost.coroutine.

    It works kind of the opposite of C# which provides generators which can be contorted into coroutines, while mx2 provides coroutines that can be contorted into generators!

    Should I add the Generator<T> class to std.fiber? Is it useful enough? I’ve certainly been thrashing the Future<T> class in ted2/mojox so that’s staying, but I haven’t needed a generator so far – or maybe I just don’t know when they’d be useful.

    I do plan on taking on ‘real’ threading one day, but it’s a BIG job and there’s still a ton of smaller jobs to be finished. And in the meantime, fibers help reduce the need for threads to a degree. I have some thoughts on how real threads could work too, might share some of them later and try to get some brian-storming going.



    Just wait until mx2lua is a bit more mature. Then you can go mental with the coroutines. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.