<!-- MHonArc v2.4.4 --> <!--X-Subject: Re: Event-driven? --> <!--X-From-R13: pbqreNvoz.arg --> <!--X-Date: from fabius.globecomm.net [207.51.48.6] by mx01.ny.us.ibm.net id 860349910.81547-1 Sun Apr 6 18:05:10 1997 --> <!--X-Message-Id: 199704061805.SAA318724#out1,ibm.net --> <!--X-Content-Type: text/plain --> <!--X-Reference: 199704040122.BAA613821#out2,ibm.net --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, Re: Event-driven?</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:coder#ibm,net"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00027.html">Previous</a> | <a href="msg00029.html">Next</a> ] Thread: [ <a href="msg00019.html">Previous</a> | <a href="msg00030.html">Next</a> ] Index: [ <A HREF="author.html#00028">Author</A> | <A HREF="#00028">Date</A> | <A HREF="thread.html#00028">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>Re: Event-driven?</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI> <LI><em>Subject</em>: Re: Event-driven?</LI> <LI><em>From</em>: <A HREF="mailto:coder#ibm,net">coder#ibm,net</A></LI> <LI><em>Date</em>: Sun, 06 Apr 97 09:27:57 -0700</LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> On 03/04/97 at 03:49 PM, Michael Hohensee <michael#sparta,mainstream.net> said: >Precisely how does an event-driven mud work? I understand the idea, but >I don't see how it could be run efficiently, and be coded neatly... >Can somebody enlighten me? Event driven eh? In the beginning there was nothing but an endless void without dimension. And then there cam an event. And the event created a change. And then there was something. And nothing was ever the same again. I'll presume that you understand the basic concepts of how an event driven system works. From there its probably easiest to detail how my system approaches being an event driven system. The following was wrtten a while ago: --<cut>-- ...I take an explicitily multi-threaded event driven approach. To describe: (please excuse typo's. I have the flu, and my eyes are burning) The server itself knows nothing about the game it is representing. It has no parser, game knowedge, or anything else application specific. All it does is represent a database. The database consists of records. Each record defines an object in the MUD world. An object may have attributes, methods, and verbs defined on it. The server is entirely event driven. Every event executes asynchronously in its own thread using a lockless model. The server core consists of the following base units: -- DB -- Dispatchor -- Executor -- Connector The Dispatchor consists of two threads which own and operate the Event List. The Event list contains an entry for every event which has been logged with the system but not processed yet. Logged events are of two forms: 1) execute at XXX time, or 2) Percentage chance of execution within time. One thread in the dispatchor handles placement of new entries onto the Event List. The other thread processes the list looking for "ripe" events (ie ones ready to be executed). Ripe events are sent to the Executor where they are placed in an Event Queue. The Event Queue is a priority queue with events ordered by their own execution priority. The Executor manages the Event pool, a local pool of threads (the number dynamically grows and shrinks at runtime depending on load) which are used to execute the events pulled off the Event Queue. Threads in the Event Pool are re-used to execute ripe events. Events are pulled off the Event Queue in priority order and handed to the first available thread. Compleated events can log futher/later events back to the Dispatchor for subsequent animation. This is how mobiles are naimated for instance. User IO arrives thru the Connector. The connector is essentially a pool of threads which asynchronously manage the general pool of outside connections. A seperate monitor is responsible for keeping the IO network tree happy. User commands arrive at the Connector and are immediately sent to the Dispatchor as Execute-In-Zero-Time (ie no delay) events. The event logged is acutally to parse the command as entered. The dispatchor then routes the event to the Executor, it runs the event and the resultant parse creates a new event which is logged with the Dispatchor to actually execute the intended action. --<cut>-- What you may note in the above, is that there are no timing loops, pulses, heartbeats, polling (gasp!) or similar. They don't exist, and I don't intend to let them exist. For anything to happen it must log an event with the Dispatchor. The Dispatchor and the Executor then collude to determine when exactly it will be executed. If there are no ripe events demanding current execution -- the server idles, and does nothing. There are no loops going on with the server running about in circles checking to see if anything needs to be done, or updating status. If there are no currently ripe evnts, the server does very very literally NOTHING. It just sits there and blocks until an event ripens. -- J C Lawrence Internet: claw#null,net ----------(*) Internet: coder#ibm,net ...Honourary Member of Clan McFud -- Teamer's Avenging Monolith... </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00027.html">Re: Mixture</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00029.html">Re: Greetings. :)</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00019.html">Re: Event-driven?</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00030.html">Re: Event-driven?</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00028"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00028"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><STRONG>Re: Event-driven?</STRONG>, <EM>(continued)</EM> <ul compact> <LI><strong><A NAME="00010" HREF="msg00010.html">Re: Event-driven?</A></strong>, Adam Wiggins <a href="mailto:nightfall#user1,inficad.com">nightfall#user1,inficad.com</a>, Fri 04 Apr 1997, 11:34 GMT </LI> <LI><strong><A NAME="00011" HREF="msg00011.html">Re: Event-driven?</A></strong>, Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Fri 04 Apr 1997, 12:23 GMT </LI> <LI><strong><A NAME="00015" HREF="msg00015.html">Re: Event-driven?</A></strong>, Shawn Halpenny <a href="mailto:rsh#dos,nortel.com">rsh#dos,nortel.com</a>, Fri 04 Apr 1997, 23:05 GMT </LI> <LI><strong><A NAME="00019" HREF="msg00019.html">Re: Event-driven?</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 06 Apr 1997, 02:14 GMT </LI> <LI><strong><A NAME="00028" HREF="msg00028.html">Re: Event-driven?</A></strong>, coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 07 Apr 1997, 01:05 GMT </LI> <LI><strong><A NAME="00030" HREF="msg00030.html">Re: Event-driven?</A></strong>, coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 07 Apr 1997, 08:34 GMT </LI> <LI><strong><A NAME="00034" HREF="msg00034.html">Re: Event-driven?</A></strong>, Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Mon 07 Apr 1997, 10:53 GMT </LI> </ul> </LI> <LI><strong><A NAME="00007" HREF="msg00007.html">Introduction</A></strong>, Shawn Halpenny <a href="mailto:malachai#iname,com">malachai#iname,com</a>, Fri 04 Apr 1997, 01:37 GMT <UL> <li><Possible follow-up(s)><br> <LI><strong><A NAME="00012" HREF="msg00012.html">Re: Introduction</A></strong>, Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Fri 04 Apr 1997, 12:45 GMT </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>