[619] in Coldmud discussion meeting

root meeting help first previous next next in chain last in chain last

Returned mail: User unknown

daemon@ATHENA.MIT.EDU (Sat Dec 17 22:41:02 1994 )

Date: Sat, 17 Dec 1994 18:17:59 -0800
From: Mailer-Daemon@netcom.com (Mail Delivery Subsystem)
To: jeffpk@netcom.com

The original message was received at Sat, 17 Dec 1994 18:17:57 -0800
from jeffpk@localhost

   ----- The following addresses had delivery problems -----
coldtuff@mit.edu  (unrecoverable error)

   ----- Transcript of session follows -----
... while talking to pacific-carrier-annex.mit.edu.:
>>> RCPT To:<coldtuff@mit.edu>
<<< 550 <coldtuff@mit.edu>... User unknown: Bad file number
550 coldtuff@mit.edu... User unknown

   ----- Original message follows -----
Return-Path: <jeffpk>
Received: by netcom9.netcom.com (8.6.9/Netcom)
	id SAA26252; Sat, 17 Dec 1994 18:17:57 -0800
From: jeffpk (Jeff Kesselman)
Message-Id: <199412180217.SAA26252@netcom9.netcom.com>
Subject: A timer object.
To: coldtuff@mit.edu
Date: Sat, 17 Dec 1994 18:17:57 -0800 (PST)
X-Mailer: ELM [version 2.4 PL23]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 2670      

I've written a first pass at a simpel timer object.  The idea was a 
minimal suite of functionality to allow 'system independance' of functions
that need a timed call back.  

Its small and should be pretty self-explanatory.  It supports two kinds 
of call backs, a one-shot (called an alarm) and a periodic (called a clock.)

How close the timing is to the timign asked for is a function of the 
period of the heartbeat.  You need to put a call to $timer.pulse() in the 
system heartbeat function.

Jeff Kesselman
---------------------------------------------------------------------
// OBJECT: timer
// PURPOSE:  Provides 2 kinds of time based callbacks.
//		alarms: an alarm provides a single call back in n seconds
//              clocks: a clock provides a repeating call back every n seconds
// AUTHOR:  Jeffrey P. Kesselman


parent $utilities
object $timer

var $root child_index 0
var $root owners [$timer]
var $root fertile 0
var $root inited 1
var $root owned [$timer]
var $root manager $timer
var $root writable [$timer]
var $root readable ['parameters, 'methods, 'code]
var $root dbref 'timer
var $timer timerCBs [] // [ [time,obj,function,args,reset_value,id]]


method init_timer
.

method pulse
	var cb,newlist, curr_time, temp;

	curr_time = time();	
	newlist = timerCBs;
	for cb in (timerCBs){
	  if ( curr_time > cb[1]){
		cb[2].(cb[3])(@cb[4]);
	        temp = cb;
		newlist = setremove(newlist,cb);
		if (temp[5] != 0){
		   newlist = [@newlist,[temp[5]+curr_time,temp[2],temp[3],
			      temp[4],temp[5],temp[6]]];
		}
	  } 
	}
        timerCBs = newlist;
.

method add_alarm
	arg obj, func, args, seconds,id;	

	if (type(seconds) != 'integer)
	   throw(~type, "Passed seconds not an integer");
	if (type(args) != 'list)
	   throw(~type, "Passed args not a list");
	if (type(obj) != 'dbref)
	   throw(~type, "Passed object not a dbref.");
	if (type(func) != 'symbol)
	   throw(~type, "Passed functio not a symbol.");
	timerCBs = [@timerCBs,[time()+seconds,obj,func,args,0,id]]; 
.

method add_clock
	arg obj, func, args, seconds, id;	

	if (type(seconds) != 'integer)
	   throw(~type, "Passed seconds not an integer");
	if (type(args) != 'list)
	   throw(~type, "Passed args not a list");
	if (type(obj) != 'dbref)
	   throw(~type, "Passed object not a dbref.");
	if (type(func) != 'symbol){
	   (> $user_catseye.tell("func type = "+tostr(type(func))) <);
	   throw(~type, "Passed function not a symbol.");
        }
	timerCBs = [@timerCBs,[time()+seconds,obj,func,args,seconds,id]]; 
.

method remove
	arg id;
	var temp;

	for temp in (timerCBs)
		if (temp[6] == id) {
		   timerCBs = setremove(timerCBs,temp);
		   return(1);
		}
	return(0);
.