[MUD-Dev] Threading and Queues (What Fun)

Ben Chambers bjchamb at bellsouth.net
Sun Feb 16 01:29:33 New Zealand Daylight Time 2003

I was considering just looping but I feel that it could potentially
introduce lag into the system.  I'm considering a system that uses
two or three threads and has MySQL as a database.  The first thread
would be input.  The second would be for processing commands.  The
first would parse commands and send them to the second thread for
execution.  The second would then put the resulting output into a
queue which would either be processed by input or by a third thread
handling output.

For the command queue I also want to use it to handle delayed
events.  Here is the system that I'm considering.  An array that has
n spaces.  Each space has a pointer to the head of two linked lists,
delayed actions (for timed actions) and immediate actions.  The
event queue processes from let us say space a of the array while the
input thread is writing to the immediate actions of space a + 1.
This way the only thing that needs to be synchronized is the space
in the array that is being written to.

I'm thinking of something semi similar for the output queue so that
there is a minimum ammount of synchronization.  Also for commands
that are social in nature (i.e require no interaction with the
database) the input queue will send the output straight to the
output queue.  I think...

Will this work as well as I think it might?  Any other ideas that
are easier?  Has anyone used threads like this before?  What about
this kind of queue?  Any other threading models that might work
better?  What is the best method of getting good performance.

MUD-Dev mailing list
MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list