1998Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev]  Event handling (was: request for comments) -->
<!--X-From-R13: Hnqvz Fxnpuraxb <inqvzgN4pf.pbz> -->
<!--X-Date: Fri, 09 Jan 1998 23:03:04 +0000 -->
<!--X-Message-Id: 34B6AC39.537F60D2#4cs,com -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.PMDF.3.95.980109154422.543193470A&#45;100000#nova,wright.edu -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev]  Event handling (was: request for comments)</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:vadimt#4cs,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="msg00154.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00156.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00153.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00198.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00155">Author</A>
&nbsp;|&nbsp;<A HREF="#00155">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00155">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev]  Event handling (was: request for comments)</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: [MUD-Dev]  Event handling (was: request for comments)</LI>
<LI><em>From</em>: Vadim Tkachenko &lt;<A HREF="mailto:vadimt#4cs,com">vadimt#4cs,com</A>&gt;</LI>
<LI><em>Date</em>: Fri, 09 Jan 1998 17:01:13 -0600</LI>
<LI><em>Sender</em>: <A HREF="mailto:vt#vadimt,4cs.com">vt#vadimt,4cs.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>
s001gmu#nova,wright.edu wrote:
&gt; 
&gt; On Fri, 9 Jan 1998, Vadim Tkachenko wrote:
&gt; 
&gt; &gt; s001gmu#nova,wright.edu wrote:
&gt; &gt; &gt;
&gt; &gt; &gt; On Thu, 8 Jan 1998, Vadim Tkachenko wrote:
&gt; &gt; &gt;
&gt; 
&gt; &lt;original question dropped&gt;
&gt; 
&gt; &gt;
&gt; &gt; [skipped]
&gt; &gt;
&gt; &gt; &gt; &gt; - One thread per connection listener (it's possible to install more than
&gt; &gt; &gt; &gt; one protocol adaptor, and therefore, connection listener)
&gt; &gt; &gt; &gt; - One thread per incoming connection
&gt; &gt; &gt;
&gt; &gt; &gt; so... at least 2 threads per user?
&gt; &gt;
&gt; &gt; Of course not - connection listener thread just accept()s the incoming
&gt; &gt; connections and
&gt; &gt; spawns the controlling thread
&gt; 
&gt; ahhh... gotcha.   I believe I am heading towards a model like this, though
&gt; if I understand what you mean by protocol adapter, I am only planning on
&gt; using one.

As I hate to recreate the same things, I eventually came to the concept
of 'protocol adaptor' as entity which gets the same data on the client
end pushes it to the server, and response all the way back (may be also
symmetrical, client may become server and vice versa) regardless of the
implementation. The only method which generic protocol should implement,
as Java interface, is

Object processRequest( Object rq ) throws Throwable;

, period. 

Currently there are:

- SocketProtocolAdaptor
- ServletProtocolAdaptor (obviously, unidirectional)
- (next to-be) CorbaProtocolAdaptor or RmiProtocolAdaptor, as my
business will influence.

&gt; &gt; - You keep at least minSpare spare request handlers, just in case, so
&gt; &gt; first minSpare incoming
&gt; &gt; requests arriving simultaneously will be served really fast.
&gt; &gt; - After some requests are finished, you keep at most maxSpare spare
&gt; &gt; request handlers, terminating anything extra (variation: after they
&gt; &gt; expire by themselves).
&gt; 
&gt; I figgured it was something like that.  True, that does seem to localize
&gt; most of the thread-creation cost to boot-time.  Especially if you pick a
&gt; decent range and initial number of threads.

Not quite, the total number of threads is changing all the time. Also, I
don't know about PThreads, but my experience with threads in OS/2 and
Java shows that call like createThread() usually returns before first
operator in that thread is executed.

&gt; &gt; Also, there are two types of requests worth mentioning:
&gt; &gt;
&gt; &gt; - packet request
&gt; &gt; - channel request
&gt; 
&gt; have to read up a bit, but I think I gather the gist of the points.. :)

Packet switching is TCP/IP, channel switching is obsolete telephone
exchangers

&gt; &gt; &gt; but when I tell my
&gt; &gt; &gt; character to "cast fireball at bubba", it becomes trivial to implement the
&gt; &gt; &gt; delay inherent to the action by scheduling the event to go off 3 ticks
&gt; &gt; &gt; down the road.
&gt; &gt;
&gt; &gt; By the way, this is exactly the point where extra threads appear in my
&gt; &gt; model. Every time-based action is asynchronously handled by the separate
&gt; &gt; thread, which allows to handle effects like spell backfires,
&gt; &gt; concentration, partial force release, accumulation rules, side effects
&gt; &gt; with extreme ease.
&gt; 
&gt; *nod*  I think I see where you are going.. the event, "cast spell" is
&gt; plunked on the queue, and handled as quickly as possible.  Handling means
&gt; calling a method which may "sleep" for a while, to take care of the delay.
&gt; If it's interrupted while sleeping (someone interrupts bubba casting the
&gt; spell), you have some sort of 'interuppted' method which handles the
&gt; results of someone busting up bubba's concentration.  Right?

You can put it this way, too.

&gt; That being the case, I'd still prefer to let events spend their delay time
&gt; on the queue, instead of in a thread.

Thus wasting more CPU cycles on event scheduling.

&gt; &gt; Just an idea: lycanthrops, whose properties change with a phase of the
&gt; &gt; moon[s]
&gt; 
&gt; mmm.. I dunno that that is really a valid concern... I am leaning more and
&gt; more towards JC's Spoof/Watcher model, which allows for such things
&gt; nicely (definately planning on spoofs.. still thinking about watchers..
&gt; dunno if my design goals necessarily coincide with the ones you chose that
&gt; lead to spoofs/watchers, JC).  W/O using watchers (to watch the phase of
&gt; the moon), I would schedule an event to go off at the beginning of the
&gt; time the lycanthrop should morph, to trigger the morph, and then one to go
&gt; off at the end of the time, to morph the poor bastich back.  No real
&gt; worries about multiple events targeting the same data at the same time, as
&gt; the events would occure once a month!  :)

I missed the concept of spoof/watcher, but if I take your meaning, you
can say that there's really no need to keep the threads running all the
time, 'cause there are certain actions/events which require
consideration of, for example, phase of the moon.

But once again, I emphasize, the difference is between treating
everything as EVENTS and PROCESSES.

&gt; &lt;handling events in list at termination/reboot&gt;
&gt; 
&gt;   &lt;two options, handle at termination or save and handle at startup&gt;
&gt; 
&gt;  &lt;my response of "mm.. maybe best to just let them die at termination&gt;
&gt; 
&gt; &gt;
&gt; &gt; Bad thing for me, because I'll have a lot of asynchronous events for
&gt; &gt; each object - for example, I'm going to implement the algorithm of
&gt; &gt; applying the temporary changes, illustrated by example:
&gt; &gt;
&gt; &gt; - You get hit by the poisoned sword.
&gt; &gt; - Consequently, there are two state changes: your limb gets a wound
&gt; &gt; (let's make it a light one), and you get poisoned.
&gt; &gt; - Wound is going to heal by itself, slowly (asynchronous process, which,
&gt; &gt; in according to the abovementioned flexibility, may have variable rate
&gt; &gt; depending on your state, weather, nutrition etc.)
&gt; &gt; - Poison is going to continue to affect you (asynchronous process), once
&gt; &gt; again, with variable rate as above.
&gt; 
&gt; mmm.. so you handle all state changes, and resulting moves back towards
&gt; the norm as an event-process?  (IE: each wound is treated as an event?)

No, as a process - even in case when, say, your limb got cut off -
there's an open wound, which may not kill you immediately, but,
nevertheless, real soon unless you move your ...

&gt; I think I'd treat the situation as a whole, rather than each individual
&gt; wound.  IE: there is one event logged (for each &lt;thing&gt; that is not at
&gt; it's normal state) which takes care of moving that thing back towards it's
&gt; normal state.  If I get a wound, it schedules the normalizer to go off
&gt; whenever, to up my hp a bit and reschedule another normalizer event.

As an increment? Probably.

&gt;  If I
&gt; get another wound, the wound event wouldn't schedule a new normalizer,
&gt; 'cause one is already pending for the previous wound.  how the normalizer
&gt; is scheduled can be as complicated as you like.

Yes, modifiers of the same type are additive - there are few parameters:

- degradation factor
- damage factor
- cumulative factor
- timeslice  

Once again, it's all described on the project pages :-)

&gt; -Greg

-- 
Still alive and smile stays on,
Vadim Tkachenko &lt;VadimT#4CS,Com&gt;
--
UNIX _is_ user friendly, he's just very picky about who his friends are

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00198" HREF="msg00198.html">Re: [MUD-Dev] Event handling (was: request for comments)</A></strong>
<ul compact><li><em>From:</em> JC Lawrence &lt;claw#under,Eng.Sun.COM&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00153" HREF="msg00153.html">Event handling (was: request for comments)</A></STRONG>
<UL><LI><EM>From:</EM> s001gmu#nova,wright.edu</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00154.html">Re: [MUD-Dev] Unique items (was: Graphic MUDS/Ultima Online)</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00156.html">Re: [MUD-Dev] Unique items</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00153.html">Event handling (was: request for comments)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00198.html">Re: [MUD-Dev] Event handling (was: request for comments)</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00155"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00155"><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]  Event handling</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<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
<UL>
<LI><strong><A NAME="00147" HREF="msg00147.html">Re: [MUD-Dev]  Event handling</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Fri 09 Jan 1998, 19:02 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00143" HREF="msg00143.html">Re: [MUD-Dev]  Event handling (was: request for comments)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Fri 09 Jan 1998, 17:50 GMT
<UL>
<LI><strong><A NAME="00153" HREF="msg00153.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, 21:51 GMT
<UL>
<LI><strong><A NAME="00155" HREF="msg00155.html">Re: [MUD-Dev]  Event handling (was: request for comments)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Fri 09 Jan 1998, 23:03 GMT
<UL>
<LI><strong><A NAME="00198" HREF="msg00198.html">Re: [MUD-Dev] Event handling (was: request for comments)</A></strong>, 
JC Lawrence <a href="mailto:claw#under,Eng.Sun.COM">claw#under,Eng.Sun.COM</a>, Sun 11 Jan 1998, 21:09 GMT
<LI><strong><A NAME="00209" HREF="msg00209.html">Event handling (was: request for comments)</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Mon 12 Jan 1998, 14:41 GMT
<LI><strong><A NAME="00222" HREF="msg00222.html">[MUD-Dev]  Event handling - some definitions</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Tue 13 Jan 1998, 00:55 GMT
</LI>
<LI><strong><A NAME="00245" HREF="msg00245.html">Re: [MUD-Dev] Event handling (was: request for comments)</A></strong>, 
JC Lawrence <a href="mailto:claw#under,Eng.Sun.COM">claw#under,Eng.Sun.COM</a>, Fri 16 Jan 1998, 04:31 GMT
</LI>
</LI>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</ul>
</ul>
</ul>
</ul>
</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>