1998Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Event Handling -->
<!--X-From-R13: "Xba O. Znzoreg" <wyflfvapNvk.argpbz.pbz> -->
<!--X-Date: Tue, 13 Jan 1998 03:35:16 +0000 -->
<!--X-Message-Id: 199801130335.VAA08979@dfw&#45;ix12.ix.netcom.com -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 34B0EEF3.5EC5402C#4cs,com -->
<!--X-Reference: 199801070052.QAA03967#under,Eng.Sun.COM -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Event Handling</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:jlsysinc#ix,netcom.com">
</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>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00222.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00224.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00078.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00117.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00223">Author</A>
&nbsp;|&nbsp;<A HREF="#00223">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00223">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Event Handling</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>: [MUD-Dev] Event Handling </LI>
<LI><em>From</em>: "Jon A. Lambert" &lt;<A HREF="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</A>&gt;</LI>
<LI><em>Date</em>: Mon, 12 Jan 1998 22:37:04 -4</LI>
<LI><em>Comments</em>: Authenticated sender is &lt;jlsysinc#popd,ix.netcom.com&gt;</LI>
<LI><em>Reply-to</em>: <A HREF="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
On  6 Jan 98 at 17:03, JC Lawrence wrote:
&gt; On Mon, 5 Jan 1998 09:10:52 PST8PDT 
&gt; Vadim Tkachenko&lt;vadimt#4cs,com&gt; wrote:
&gt; &gt; Jon A. Lambert wrote:
&gt; 
&gt; &gt;&gt; Variations on event-driven design
&gt; 
&gt; &gt; Can you please elaborate on that?
&gt; 
&gt; There are a couple base models going about the list.  Jon and I have
&gt; some of the more intricate designs.  I'll let Jon describe his.
&gt; 

Alrighty!  A request to delve back into the low-level nitty gritty details. 
I posted some definitions in another message and I won't elaborate on them 
here except to state that event-driven systems may be single-threaded or
multi-threaded.  They may even be soft-threaded (cf. Cynbe ru Taren's MUQ). 
This is rather obvious since ColdX, MudOS and some others implement 
mechanisms for event processing.  They are hybrids of the procedural and 
event models.  

JC's model and my own are hybrids of all three models, but at the language 
or mudlib programming model they will likely exhibit the traits of a 
concurrent processing model. Invariably we touch on threads and data 
concurrency/consistency that one might serialize and largely ignore in a 
single-threaded event-driven system.  So...here is how I stand right now... 

&gt; To describe my system loosely, and briefly:
&gt; 
&gt;   The server is heavily multi-threaded (I think the idle-state is over
&gt; 50 threads currently).
&gt;

My model currently has a fixed pool of threads and is strongly 
partitioned and layered.

    Network subsystem - 1 thread to listen for connections and
          1 thread per connection.   Threads are created and destroyed
          as needed.  May be a good candidate for pooling later...
    Dispatcher - 1 thread - pops events off the queue and places in proper
          Executor class. 
    Executor - 6 threads - 3 for normal activity, 1 real-time monitor
          thread, 1 low-priority and 1 lazy priority(*) thread    
    Object manager - consists of 4 threads , Lock subsystem, Cache 
          subsystem, Database subsystem and Logging subsystem. 

&gt;   All events are processed aynchoinously and in parallel.  
&gt;

Nod.  'cept mine are asynchronous. :P
 
&gt;   The server is lockless.

I do object locking.  My model is based on IBM's DB2 which will attempt to 
spin-lock an object.  A lock is attempted several times for a brief 
duration (milli-seconds).  If failure occurs, the event is rescheduled.  
Logging is very very DB2ish also.  The primary purpose of logging is
recovery from literally pulling the plug and insuring backups maintain
data synchronization. 

&gt;   I don't guarantee order of execution of two unrelated events.
&gt; 
&gt;   The base design:
&gt; 
&gt;     Events are logged with the Dispatchor in the Event List as a tuple
&gt; of an object:method call, various arguments, various ownership data,
&gt; and either a state time the event is to start execution, or a
&gt; percentage chance value that the event will start execution within any
&gt; given minute.
&gt;

Similarly I keep Object:method and parameter stack, the event state time 
and an event class (0-3) indicator - 0 is monitor class, 1 is normal class, 
2 is low-level and 3 is lazy priority.  (*)Lazy priority threads bypass all 
object locking read or write, they simply do not care about data integrity. 
This is used for low-level SIM processes, which do tallying of current 
state.  My event queue object is ordered at insert.

&gt;   The Dispatchor procresss the Event List, sending ripe events to the
&gt; Executor.
&gt; 
&gt;   The Executor receives the ripe events from the Dispatchor and stores
&gt; them in priority order in teh Event Queue.
&gt;
&gt;   The Excutor processes the events in priority order by handing them
&gt; for processing to to the Event Pool, a dynamically sized pool of
&gt; threads.
&gt; 

I'm a bit different here also.  The Dispatcher places the event data in
the appropriate Executor data area and starts the Executor thread.  
Executor threads will generate events which are inserted into the Event 
queue by the executing thread. 

&gt;   Events that fail to commit are rescheduled with the Executor at a
&gt; different priority.
&gt;

Nod. My priority does not change however, the state time is incremented.
 
&gt;   Event's have no effect upon the DB or state until and unless they
&gt; commit.
&gt; 

Upon an executor threads successful termination pointers are swizzled in 
the cache and locks are freed.  Upon unsuccessful termination locks are
freed.  Each event is equivalent to a application consistent transaction.  
The Object cache contains two copies of objects (before/after) when write 
locks are requested.

BTW, I have flipped my language model around.  Instead of writing 
specialized _event_ methods, I have two forms of method calls.  One will
cause the method to be immediately invoked, the other schedules the
call as an event w/time and class.  Seems to make lib programming much 
easier.  Also, I have given up all attempts to pre-bind methods at compile 
time to the objects they may be interested in (a way of pre-locking at 
execution start up).  The dynamic nature of the object requests makes this 
just silly.

Comments, criticisms, or vicious personal attacks welcome. :)

--
Jon A. Lambert
"Everything that deceives may be said to enchant" - Plato

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00026" HREF="msg00026.html">Re: [MUD-Dev]  request for comments (was: Mud-Dev FAQ)</A></STRONG>
<UL><LI><EM>From:</EM> Vadim Tkachenko &lt;vadimt#4cs,com&gt;</LI></UL></LI>
<LI><STRONG><A NAME="00078" HREF="msg00078.html">Re: [MUD-Dev] request for comments (was: Mud-Dev FAQ)</A></STRONG>
<UL><LI><EM>From:</EM> JC Lawrence &lt;claw#under,Eng.Sun.COM&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00222.html">[MUD-Dev]  Event handling - some definitions</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00224.html">[MUD-Dev] Simulations - was: 'A flamewar startingpoint.'</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00078.html">Re: [MUD-Dev] request for comments (was: Mud-Dev FAQ)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00117.html">request for comments (was: Mud-Dev FAQ)</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00223"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00223"><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: [MUD-Dev]  request for comments (was: Mud-Dev FAQ)</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00026" HREF="msg00026.html">Re: [MUD-Dev]  request for comments (was: Mud-Dev FAQ)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Mon 05 Jan 1998, 14:34 GMT
<UL>
<LI><strong><A NAME="00033" HREF="msg00033.html">Re: [MUD-Dev]  request for comments (was: Mud-Dev FAQ)</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Mon 05 Jan 1998, 21:05 GMT
</LI>
<LI><strong><A NAME="00050" HREF="msg00050.html">Re: [MUD-Dev]  request for comments (was: Mud-Dev FAQ)</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Tue 06 Jan 1998, 05:32 GMT
</LI>
<LI><strong><A NAME="00078" HREF="msg00078.html">Re: [MUD-Dev] request for comments (was: Mud-Dev FAQ)</A></strong>, 
JC Lawrence <a href="mailto:claw#under,Eng.Sun.COM">claw#under,Eng.Sun.COM</a>, Wed 07 Jan 1998, 00:52 GMT
<UL>
<LI><strong><A NAME="00223" HREF="msg00223.html">[MUD-Dev] Event Handling</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Tue 13 Jan 1998, 03:35 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00117" HREF="msg00117.html">request for comments (was: Mud-Dev FAQ)</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Thu 08 Jan 1998, 16:43 GMT
<UL>
<LI><strong><A NAME="00122" HREF="msg00122.html">Re: [MUD-Dev]  Event handling (was: request for comments)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Thu 08 Jan 1998, 20:13 GMT
<UL>
<LI><strong><A NAME="00141" HREF="msg00141.html">Event handling (was: request for comments)</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Fri 09 Jan 1998, 16:11 GMT
<UL>
<LI><strong><A NAME="00144" HREF="msg00144.html">Re: [MUD-Dev]  Event handling</A></strong>, 
Shawn Halpenny <a href="mailto:malachai#iname,com">malachai#iname,com</a>, Fri 09 Jan 1998, 17:50 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</ul>
</ul>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>