(no subject)

From: Daniel W. Burke (dwb@ix.netcom.com)
Date: 12/15/98


Is anyone comfortable with the STL? (well, I'm sure SOMEONE is)...

I just recently decided it was time to learn the STL... and I came to
the priority_queue template... I started thing about if this would be
useful for an event system, and wanted to get a little input from anyone
that knows the template...

This is a VERY ROUGH draft of what I had in mind...

class event_type {
 public:
   operator int() { return when; };
   event_type() { };
   ~event_type() { };

   time_t when;
   void EVENTF(*func)();
};


  priority_queue<event_type, vector<event_type>, greater<int> > Q;


  event_type event;

  event.when = time(0) + 10;
  // Initialize other event stuff here

  Q.push(event);


void event_process()
{
  event_type *e;
  int now = time(0);

  while (!Q.empty() && (*e = Q.top()) && (e->when >= now)) {
    // process the event
    (e->func)();
    Q.pop();
  }

}



Half of this was mailer code, so that my test code made sense to someone
else ;)  Good idea?  Bad idea?  Or is there any point whatsoever?  Or
is there a better solution?  Our current event system cannot handle the
load I want to put on it, (in the range of 10000 events), so I want to
push it as high as I possibly can without bringing the mud to a standstill
so it can process events all day.  I'm sure this will work, but I don't
want to be taking a step back in efficency, even though this would be
easier to handle.  Any input/feedback would be appreciated :)

Brazil


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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