Re: [INFO NEEDED][SEMI-CODE] Event based queue

From: Gary Barnett (gbarnett@POLARNET.COM)
Date: 11/01/97

On Friday, October 31, 1997 10:24 PM, Daniel Koepke
[SMTP:dkoepke@CALIFORNIA.COM] wrote:
> On Fri, 31 Oct 1997, Doppleganger Software wrote:
> ->  <<time_data>> time_of_event_to_occur;
> The easiest way would be to just make it an integer and have
> heartbeat() update the counter every second (or however slow/fast you
> want it updated).
By checking each entry in the queue for being a particular value you add one
difficulty. The value will eventually roll over due to variable size

A routine that decrements the time left and then fires the event when the
time has
been reached avoids this problem. That's how I've implemented the various
queues on my mud. Granted changing a variable's value incurs extra overhead
just comparing it. You don't have to check the specials cases though, so it's
probably a wash processor time wise.

> ->    if (<<incoming->time_of_event is before test->time_of_event>>)
> ...which would make this a simple, "if (incoming->time <= test->time)"
> ->    if (<<test->time_of_event is equal or before current_time>>) {
> and this would be changed to, "if (!(--test->time))"
> Yes, it's a very basic solution, but it works, it's simple, and
> trivial to implement (then again, I seem to call a lot of stuff
> "trivial" without ever checking if they are, in fact, trivial to code;
> but it seems fairly simple [to me], so this might actually be
> trivial).
The first queue is a real PITA. The rest are trivial :-)


Neither sweat, nor blood, nor frustration, nor lousy manuals
nor missing parts, nor wrong parts shall keep me from my task.
  --Christopher Hicks

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST