[MUD-Dev] [TECH] Event Queue System
Kwon Ekstrom
justice at softhome.net
Sun Feb 17 13:27:17 CET 2002
From: <the_sage2000 at juno.com>
> 1) Has anyone implemented an event queue system and can give me
> advise on doing it?
> 2) Can anyone give me more information on it than what I am about
> to present?
I'm currently working on my own codebase, and am using a mixed
polling/event system. I find that it's much simpler to handle
regularly scheduled tasks with a polling system and events are
generally used for localized happenings within the mud to create a
diverse and easily extendable set of behaviors and responces.
I use an event/listener system where events are children of the
Event class. Listeners are any class that implements the Listener
interface (I'm writing in Java). The event's job is simply to
maintain data concerning the event, and using that data to propogate
itself to any interested listener. The listener's job is to
determine if it can handle an event that is passed to it. An event
does nothing in itself, it's the listeners that react to the event
that make it work.
Event is an abstract class with alot of built-in behaviors. Common
distribution routes are built into this class to make it easy to
create new events, along with a "dispose" method to toggle a boolean
to abort any further processing. There's also a "delay" event queue
to allow an event to be handled at a later time.
My polling system actually uses a delayed event to schedule
themselves. Alot of pre-optimization is handled using events in
this manner. On the side, I use an external thread to check the
delays, and push "mature" events onto a stack to be handled upon the
next pulse.
Anyway, I find that although there's alot of complex code to get
this to work correctly, it's easy to extend (since most behavior is
defined already), and makes it amazingly simple to create advanced
behaviors.
There's alot of subtle details that allow quick execution that I'd
be willing to go over if anyone is interested.
-- Kwon J. Ekstrom
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list