I've wanted to re-start this game, but only recently embarked on this, and decided a better backend for this game would be .NET whose native support for threads and co-routines (async/await) is significantly stronger,

I don't use the CB that much, so I don't have a lot to say there, but I'm very interested in the topic of threading :-)

What sort of workload does this game run that would benefit from C# style threading? I ask because I also have an interest in online game servers, and from my experiences with Java, decided that I wouldn't want to do it that way; locking access to the different data structures can get very complex, adds a lot of cognitive overhead, and is generally hard to debug. Meanwhile, if the threads are acting on behalf of stateful user connections, they don't scale well. If you need threads because there are too many user connections for one thread to handle, I would rather have multiple worker processes that load-balance the connections and exchange their data through a shared state in a database.

But, maybe threading was a secondary goal and your main desire is the async/await coroutines? If your game (like the one I was tinkering with) is a MUD, you might find in the end that async/await isn't that great of a fit. Async/Await makes it easy to write scripted events as a natural tree of function calls, each of which can divert to wait for other events to complete, but this structure doesn't "checkpoint" well. There is no way to tell the server to save all that state and exit so that you can upgrade the code and pick up where it left off. If you instead design the scripted workload as a list of state machines, you can save that off to a table and then pick it up in a new process (maybe after patching some bugs or something) and the state machines can carry on right where they left off. You can even save off the state machines if all the players exit the area where it would have visible effects, and load them back up when players re-enter the area. It also lets you pass the workload for an area between threads/processes so that events occurring in a local area can keep the state local and not need as many database accesses.

If your game server was for a 3D shooter that needs to validate lots of collision checks on a shared 3D collection of polygons, then I totally see the C# advantage. ...but mainly for the shared data structures and speed. I would still choose to write that kind of a server using state machines :-)


In reply to Re: CB stats, Last hour of CB by NERDVANA
in thread CB stats, Last hour of CB by Tanktalus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.