[DGD] Heart beat and alternatives?
Stephen Schmidt
schmidsj at union.edu
Fri Oct 5 06:24:31 CEST 2001
On Thu, 4 Oct 2001, Par Winzell wrote:
> I've been trying to figure out recently what a modern mudlib should
> support in terms of heartbeat-like functionality....
> Has anybody else thought about this? Is 3) too general?
No, I don't think it is. One might want to have some security
about what users or objects can create an indefinite series
of calls, but I think some sort of function for this is
necessary for almost all interesting contexts. There are
always objects that need regular updating, even in pure
game contexts (healing is the obvious example) and it does
seem to me that wizards who lack the ability to code their
own callout chains may need a function to do it for them
(alternatively, it is better to give them a good function
to do it rather than endure the consequences when they try
to code their own and fail).
> I think it's not too general. So then what would be a sane API?
A simple function declaration might be
int heart_beat (int frequency, varargs start_time) ;
where frequency is the number of seconds between calls, and
start_time is the absolute time reference at which to start.
Those who wish to say "start calling this function every
ten minutes, one minute from now" can pass time()+60 as the
start_time argument. If you want it instantly, pass -1 as
the start time (of course, time() would work too).
If you want all three calls to go through the same API, then
you can allow 0 or -1 as the frequency argument to mean
"do this only once." I think I would view it as more natural
to just let people use call_out for one-shot deals, though.
One might also want to broaden the interface to allow the
units of time to be minutes, hours, days, etc, rather than
seconds.
Did you want more than that? These technical terms like "API"
do throw the undereducated like me at times :)
Steve
Sweet words can buy honor
Good deeds can gain respect
If a man is bad, do not abandon him.
- Tao Te Ching, chapter sixty-two
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list