So in an event-driven server, how do you ...

Nathan Yospe yospe at
Mon Apr 7 10:42:02 New Zealand Standard Time 1997

On Mon, 7 Apr 1997, Michael Hohensee wrote:

:It looks like you guys hate polling.  (Not that I blame you, I don't 
:really like it myself. :)  But if you've got a system that just sits 
:until the next "ripening", how do you do your IO with players?  Do you 
:use an endless loop to poll the connections?  Or do you use the SIGIO 

I'm not sure about the others, but I have a thread for each connection,
set to wait for the condition buffer.notEmpty(). It begins char peeking on
the buffer with the first character... if the input is an instant
(control, or editor, or such) it wakes up and starts processing. If not,
it sets itself to wait for the condition buffer.lineReturned(), and grabs
all completed lines, sending them off to appropriate destinations. One of
these destinations is the Character interpreter, which instantly
interprets and drops on the local queue. (running off of the socket
thread, not the queue's thread) The queue grabs all of these at its own
leisure (meaning the moment it has a free cycle.)

:I tried to use both.  I poll for new commands from the players, and use 
:the SIGIO signal to hook up a new connection.  More than a little bit 
:dirty.  It doesn't work under BSD, then I have to poll for everything.

I'm not sure about BSD, but I think there is a pThreads port for it, and
letting the threads handle polling of that sort is a lot more efficient
and effective, in my experience. I'm not sure how the implementation of
BSD would do it, but most thread implementations support low profile
polling in their wait() implementations.

:Michael Hohensee
:Eagleson's Law:
:        Any code of your own that you haven't looked at for six or more
:months, might as well have been written by someone else.  (Eagleson is
:an optimist, the real number is more like three weeks.)

*chuckle* He's right. I'm trying to pick apart some code I wrote three
years ago. What _is_ this stuff, and who wrote it, so I can track him down
and _shoot_ him.

   __    _   __  _   _   ,  ,  , ,  
  /_  / / ) /_  /_) / ) /| /| / /\            First Light of a Nova Dawn
 /   / / \ /_  /_) / \ /-|/ |/ /_/            Final Night of a World Gone
Nathan F. Yospe - University of Hawaii Dept of Physics - yospe at

More information about the MUD-Dev mailing list