[SDL] [Framework] Event-based Networking
Nathaniel J Fries
nfries88 at yahoo.com
Mon Mar 18 19:27:59 PDT 2013
> Nathaniel J Fries wrote:
> > [...] you will quickly find a bottleneck at mutually exclusive code, generally at ~50 clients (and it will become unbearable by the time you reach 100).
> Ah okay, that's the point :) I think I'll put this to my todo-list. MMORPG is a very specific genre but - as you said - a possible case of using networking frameworks ^^ So you're right :)
> But to go more in detail: Can problem about accessing mutual exclusive code (I hope I'm right: locking common resources with a mutex? :D ) be diminished by using std::mutex or so?
> Does anybody else likes to comment on my framework? :)
Mutexes are the source of the bottleneck (using binary semaphores, critical sections, condition variables, or spinlocks will have the same effective result, and the same effective problem). Mutex is short for "mutual exclusion", so when I said "mutually exclusive code", I literally meant "code that uses mutexes".
If you don't use mutexes, you wouldn't have a bottleneck, you'd have something way worse -- code that compiles just fine but doesn't work at all!
Anyway, the cleverness I talked of involves using non-blocking I/O on sockets (via SDLNet_SocketReady() IIRC) and SDLNet_CheckSockets() to drive a single network thread. You could optimize this some with a thread-per-processor and doing some load balancing, but ultimately it would still fall well short of what is provided by I/O Completion Ports, epoll, kqueue, or whatever other operating systems provide, and which boost.asio cleverly wraps.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL