Event handling (was: request for comments)

s001gmu at nova.wright.edu s001gmu at nova.wright.edu
Mon Jan 12 09:41:32 CET 1998


On Sun, 11 Jan 1998, JC Lawrence wrote:

> On Fri, 9 Jan 1998 15:00:37 PST8PDT 
> Vadim Tkachenko<vadimt at 4cs.com> wrote:
> 
> > But once again, I emphasize, the difference is between treating
> > everything as EVENTS and PROCESSES.
> 
> Note: "event" is actually a very poor term for what we are describing
> here.  They really aren't events, but I'm unsure of a better name for
> them.  

Actions?   

> What is the difference between your model of a "process", and a paced
> series of events such as one that:
> 
>   1) Dig portion of Panama Canal
>   2) Log new event to dig portion of Panama Canal in X time.
>   3) Exit
> 
> Where little tiny events are chained thru time to create the apparency
> of an ongoing process?  (You could consider each #1 above as say the
> moving of one shovel of dirt).
>   
> > 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 ...
> 
> Certainly.  You create an event chain (as above) which iteratively saps
> the character's strength and vitality.  Should that process happen to
> kill the character (strength == 0?) then this will be noticed by the
> normal methods of the character object (probably in the accessor for
> the strength attribute) and processed from there.

As I understand it, the only difference is that he shortcuts the event
chain by having the running thread (process in his terms) handle all of
the delays by going to sleep, rather than scheduling a new event to go off
X ticks down the road.

There are some advantages to doing it that way... You can have the thread
sleep by using pthread_cond_timedwait (assuming you are using posix
threads) , and use the condition var as an interrupt signal, allowing for
very gracefull interruption and interrupt handling.  If you want to
interrupt a pending event in an event queue, you have to search the queue,
or have some kludgy structure imposed above the queue to allow for easier
access, etc.

-Greg




More information about the mud-dev-archive mailing list