About Monkey 2 › Forums › Monkey 2 Development › Generator ?
This topic contains 5 replies, has 4 voices, and was last updated by
Samah 2 years, 9 months ago.
-
AuthorPosts
-
July 19, 2016 at 10:21 am #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?
July 19, 2016 at 11:19 am #2277Mark 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
July 19, 2016 at 11:22 am #2278Aha! Great! Thanks
July 21, 2016 at 7:39 am #2313Played 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)
July 22, 2016 at 12:32 am #2325Yeah, 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.
July 22, 2016 at 1:11 am #2326Just wait until mx2lua is a bit more mature. Then you can go mental with the coroutines.
-
AuthorPosts
You must be logged in to reply to this topic.