1998Q3/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine -->
<!--X-From-R13: f001tzhNabin.jevtug.rqh -->
<!--X-Date: Tue, 21 Jul 1998 06:49:59 &#45;0700 -->
<!--X-Message-Id: Pine.PMDF.3.95.980721092751.541211270B&#45;100000#nova,wright.edu -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.LNX.3.96.980721093627.512E&#45;100000#andridys,ip.local -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Eng</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:s001gmu#nova,wright.edu">
</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="msg00276.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00278.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00273.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00300.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00277">Author</A>
&nbsp;|&nbsp;<A HREF="#00277">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00277">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: "<A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A>" &lt;<A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A>&gt;</LI>
<LI><em>Subject</em>: [MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</LI>
<LI><em>From</em>: <A HREF="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</A></LI>
<LI><em>Date</em>: Tue, 21 Jul 1998 09:48:19 -0400 (EDT)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</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 Tue, 21 Jul 1998, Oliver Jowett wrote:

&gt; On Mon, 20 Jul 1998 s001gmu#nova,wright.edu wrote:
&gt; 
&gt; &gt; On Sat, 18 Jul 1998 oliver#jowett,manawatu.planet.co.nz wrote:
&gt; &gt; 
&gt; &gt; &gt; Why not move this to a separate layer? At the lowest level, select() on
&gt; &gt; &gt; ALL sockets with a timeout equal to the time to next pending event. When
&gt; &gt; &gt; input arrives, read and buffer; when output is possible, write from a
&gt; &gt; &gt; buffer; when exceptions occur, set an appropriate flag. Loop back and
&gt; &gt; &gt; repeat the select. Then when the event actually goes off, you check and
&gt; &gt; &gt; modify the buffers.
&gt; &gt; 
&gt; &gt; This works nicely, as long as you have a tick based event queue.  The
&gt; &gt; model I use is based on the system clock, and uses a linked list as the
&gt; &gt; main structure.  With one cpu, it is physically quite impossible to
&gt; &gt; schedule two events at exactly the same time (and with multiple it is
&gt; &gt; quite unlikely), so I don't need any auxiliary linked lists to handle
&gt; &gt; collisions.  The problem is that my event driver sleeps until the next
&gt; &gt; event is scheduled to go off, OR another event is placed first in the
&gt; &gt; list.  If the later happens, not only would I have to wake up the event
&gt; &gt; driver, but I'd also have to interrupt the select, and then reschedule it
&gt; &gt; with a new timeout.
&gt; 
&gt; I'm not quite clear about how your timing system works - it sounds like a
&gt; "tick-based" system which has a much finer (and externally-run, although
&gt; that shouldn't affect much) timing resolution? 

To be honest, it is tick based, I just use the system clock as my
'ticker'.  :)  What I do is schedule events with an offset:

  EventHandler E = new EventHandler ();
  ...
  E.AddEvent(new UselessEvent(), 300);

where 300 is the offset.  EventHandler::AddEvent takes the offset and adds
it to the current system time, and then places the event in the queue
based on the resulting ripening time:

  EventHandler::AddEvent(Event e, int offset)
  {
    ...
    TIME t = current_time();
    t += offset;
    e.ripens = t;
    &lt;insert into linked list, orderd on e.ripens&gt;  
    ...
  }

so, yes, it is 'tick-based', but only inasmuch as the computer is tick
based.  I don't impose any artificial ticks on top of the system ticker.
:)  I do allow for the definition of a GRAIN, but that is only for
shorthand.  It gets a bit cumbersome to schedule an event to go off in one
week of real time if you have to measure it down to the nanosecond.  The
Grain is just an int multiplied to the offset before it is added to the
current time:

  t += offset * GRAIN;

&gt; If you're working with a single thread - how do events get added without
&gt; either I/O occuring or an event happening first? Signals, I guess. 
&gt; Personally I avoid using signals for anything short of exceptional
&gt; external circumstances where possible :)

I am working with multiple threads.

&gt; With multiple threads I'm not quite sure why you'd want to have the event
&gt; system timing tied into I/O waits anyway.

And the above was exactly my point, for the way I have my driver set up.
In Todd's design, he imposes a 'ticker' on top of the system clock, where
each tick is of a fixed and known length.  Therefore, as long as he
doesn't try to remove that design spec, he should be ok in putting the
select call to sleep for the length of one of those ticks.

I dislike this approach, because it ties the socket handler and the event
driver together (as I've stated before).  I do like the idea of having a
single event for each socket, as discussed in my last post, but I want to
do some test runs to see how it would work out... I am unsure how well it
will scale, and at what point the event handler would get swammped with
I/O events.

-Greg




</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="00300" HREF="msg00300.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>
<ul compact><li><em>From:</em> Joel Kelso &lt;joel#ee,uwa.edu.au&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00273" HREF="msg00273.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
<UL><LI><EM>From:</EM> Oliver Jowett &lt;oliver#jowett,manawatu.planet.co.nz&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00276.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00278.html">[MUD-Dev] Re: WIRED: Kilers have more fun</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00273.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00300.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00277"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00277"><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>[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00248" HREF="msg00248.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Todd Lair <a href="mailto:tlair#mailzone,com">tlair#mailzone,com</a>, Sat 18 Jul 1998, 05:18 GMT
<UL>
<LI><strong><A NAME="00249" HREF="msg00249.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
oliver <a href="mailto:oliver#jowett,manawatu.planet.co.nz">oliver#jowett,manawatu.planet.co.nz</a>, Sat 18 Jul 1998, 06:27 GMT
<UL>
<LI><strong><A NAME="00269" HREF="msg00269.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Mon 20 Jul 1998, 15:57 GMT
<UL>
<LI><strong><A NAME="00273" HREF="msg00273.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Oliver Jowett <a href="mailto:oliver#jowett,manawatu.planet.co.nz">oliver#jowett,manawatu.planet.co.nz</a>, Mon 20 Jul 1998, 21:51 GMT
<UL>
<LI><strong><A NAME="00277" HREF="msg00277.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Tue 21 Jul 1998, 13:49 GMT
<UL>
<LI><strong><A NAME="00300" HREF="msg00300.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Joel Kelso <a href="mailto:joel#ee,uwa.edu.au">joel#ee,uwa.edu.au</a>, Wed 22 Jul 1998, 02:21 GMT
<UL>
<LI><strong><A NAME="00305" HREF="msg00305.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Wed 22 Jul 1998, 13:30 GMT
</LI>
<LI><strong><A NAME="00311" HREF="msg00311.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Wed 22 Jul 1998, 17:54 GMT
</LI>
<LI><strong><A NAME="00317" HREF="msg00317.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Adam Wiggins <a href="mailto:adam#angel,com">adam#angel,com</a>, Wed 22 Jul 1998, 20:43 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</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>