Comments on: Implementing Fibers in C# I considered IEnumerable based fibres for one of my own XNA projects. For me it falls down if you want to start breaking your fibre code into smaller methods. In order to yield execution in a called method, the caller must call it like: <pre>foreach (int i in SubMethod()) yield return i;</pre> Which I guess is workable, if a bit verbose. Also, returning a value from a method is problematic, as the return value has already been used for the iterated set concept. I'd be interested if you have any ideas in this area..? To be honest, I was a little frustrated that C# doesn't have more explicit fibre support, as they've solved all the hard problems already. I considered IEnumerable based fibres for one of my own XNA projects. For me it falls down if you want to start breaking your fibre code into smaller methods. In order to yield execution in a called method, the caller must call it like:

foreach (int i in SubMethod()) yield return i;

Which I guess is workable, if a bit verbose.

Also, returning a value from a method is problematic, as the return value has already been used for the iterated set concept. I’d be interested if you have any ideas in this area..?

To be honest, I was a little frustrated that C# doesn’t have more explicit fibre support, as they’ve solved all the hard problems already.

]]>
By: Sean Parsons/2011/05/25/implementing-fibers-in-c/#comment-4874 Sean Parsons Wed, 25 May 2011 19:29:25 +0000 You would only have one extra live object per method returning an IEnumerable. In practice, I have yet to see this become a problem. Every Unity3D game uses this pattern when you write code with C# or Javascript (they have some nice syntactic sugar for Javascript) to support the yield pattern. Every bit of AI in Unity is powered by this technique You would only have one extra live object per method returning an IEnumerable.

In practice, I have yet to see this become a problem. Every Unity3D game uses this pattern when you write code with C# or Javascript (they have some nice syntactic sugar for Javascript) to support the yield pattern. Every bit of AI in Unity is powered by this technique

]]>
By: kalin/2011/05/25/implementing-fibers-in-c/#comment-4841 kalin Wed, 25 May 2011 08:55:36 +0000 The actor model would be a nice alternative, each fiber would be an actor, for .Net it looks like MailboxProcessor from F# is probably the best bet. The actor model would be a nice alternative, each fiber would be an actor, for .Net it looks like MailboxProcessor from F# is probably the best bet.

]]>
By: Kevin Gadd/2011/05/25/implementing-fibers-in-c/#comment-4834 Kevin Gadd Wed, 25 May 2011 05:31:39 +0000 Yes, absolutely true. This is a simplified version for demonstrating the concept without getting muddled up with other issues. Yes, absolutely true. This is a simplified version for demonstrating the concept without getting muddled up with other issues.

]]>
By: Miguel de icaza/2011/05/25/implementing-fibers-in-c/#comment-4832 Miguel de icaza Wed, 25 May 2011 03:47:05 +0000 i'd be worried about your high use of objects for this system. on the pc the GC is good enough to handle it no problem, but if you tried to use such a system for a game ported to the xbox or wp7, it would most likely have large difficulties with object cleanup in the GC not saying this is without merit, but it's a concern you should probably investigate before using this for a production system/game i’d be worried about your high use of objects for this system. on the pc the GC is good enough to handle it no problem, but if you tried to use such a system for a game ported to the xbox or wp7, it would most likely have large difficulties with object cleanup in the GC

not saying this is without merit, but it’s a concern you should probably investigate before using this for a production system/game

]]>
By: Kevin Gadd/2011/05/25/implementing-fibers-in-c/#comment-4829 Kevin Gadd Wed, 25 May 2011 03:23:39 +0000