diff --git a/src/modules/call_out/call_out.c b/src/modules/call_out/call_out.c index 6e2a6e7ca935870c241878754789beb7eaac939f..513419a3c3583dca4519ea61ca92c5d753fb0d2b 100644 --- a/src/modules/call_out/call_out.c +++ b/src/modules/call_out/call_out.c @@ -71,7 +71,7 @@ static void verify_call_outs() /* start a new call out, return 1 for success */ -static int new_call_out(int num_arg,struct svalue *argp) +static struct array * new_call_out(int num_arg,struct svalue *argp) { int e,c; call_out *new,**p,**pos; @@ -161,7 +161,8 @@ static int new_call_out(int num_arg,struct svalue *argp) num_pending_calls++; verify_call_outs(); - return 1; + + return new->args; } static struct callback *call_out_backend_callback=0; @@ -170,6 +171,7 @@ void do_call_outs(struct callback *ignored, void *ignored_too, void *arg); void f_call_out(INT32 args) { struct svalue tmp; + struct array *v; if(args<2) error("Too few arguments to call_out.\n"); @@ -181,7 +183,9 @@ void f_call_out(INT32 args) sp[-args]=sp[1-args]; sp[1-args]=tmp; - new_call_out(args,sp-args); + v=new_call_out(args,sp-args); + v->refs++; + push_array(v); /* We do not add this callback until we actually have * call outs to take care of. @@ -250,11 +254,16 @@ void do_call_outs(struct callback *ignored, void *ignored_too, void *arg) static int find_call_out(struct svalue *fun) { int e; + + if(fun->type == T_ARRAY) + for(e=0;e<num_pending_calls;e++) + if(pending_calls[e]->args == fun->u.array) + return e; + for(e=0;e<num_pending_calls;e++) - { if(is_eq(fun, ITEM(pending_calls[e]->args))) return e; - } + return -1; } @@ -370,10 +379,10 @@ void verify_all_call_outs() void init_call_out_efuns(void) { - add_efun("call_out",f_call_out,"function(function,float|int,mixed...:void)",OPT_SIDE_EFFECT); + add_efun("call_out",f_call_out,"function(function,float|int,mixed...:mixed)",OPT_SIDE_EFFECT); add_efun("call_out_info",f_call_out_info,"function(:array*)",OPT_EXTERNAL_DEPEND); - add_efun("find_call_out",f_find_call_out,"function(function:int)",OPT_EXTERNAL_DEPEND); - add_efun("remove_call_out",f_remove_call_out,"function(function:int)",OPT_SIDE_EFFECT); + add_efun("find_call_out",f_find_call_out,"function(mixed:int)",OPT_EXTERNAL_DEPEND); + add_efun("remove_call_out",f_remove_call_out,"function(mixed:int)",OPT_SIDE_EFFECT); } void init_call_out_programs(void) {} diff --git a/src/modules/call_out/doc/call_out b/src/modules/call_out/doc/call_out index 6eccf4ad52d699ec35fa1bbded0fbf4a5fd4886a..33d3446c86e32d0d83dec1cd2201cce7a9b433bd 100644 --- a/src/modules/call_out/doc/call_out +++ b/src/modules/call_out/doc/call_out @@ -2,11 +2,13 @@ NAME call_out - make a delayed call to a function SYNTAX - void call_out(function f, int delay, mixed ... args); + mixed call_out(function f, int delay, mixed ... args); DESCRIPTION Call_out places a call to the function f with the argument args - in a queue to be called in about delay seconds. + in a queue to be called in about delay seconds. The return value + identifies this call out. The return value can be sent to + find_call_out or remove_call_out to remove the call out again. SEE ALSO remove_call_out, find_call_out, call_out_info diff --git a/src/modules/call_out/doc/find_call_out b/src/modules/call_out/doc/find_call_out index 39e39cc45623d174d909bfd9f8c2b597b20ab876..019ea4d2fe7e9f46433958f31c77d85a716e8179 100644 --- a/src/modules/call_out/doc/find_call_out +++ b/src/modules/call_out/doc/find_call_out @@ -3,10 +3,16 @@ NAME SYNTAX int find_call_out(function f); + or + int find_call_out(mixed id); DESCRIPTION - This function searches the call out queue, and returns the time left - to this call out will be done in seconds. If no call is found, + This function searches the call out queue. If given a function as + argument, it looks for the first call out scheduled to that function. + The argument can also be a call out id as returned by call_out, in + which case that call_out will be found. (Unless it has already been + called.) find_call_out will then return how many seconds remains + before that call will be executed. If no call is found, zero_type(find_call_out(f)) will return 1. SEE ALSO diff --git a/src/modules/call_out/doc/remove_call_out b/src/modules/call_out/doc/remove_call_out index 277cc9eb0a2bd30f93927a221591ca394f776116..b730c6ed7df15bcf0ed39fe0c766b799d8cf53f0 100644 --- a/src/modules/call_out/doc/remove_call_out +++ b/src/modules/call_out/doc/remove_call_out @@ -3,12 +3,15 @@ NAME SYNTAX int remove_call_out(function f); + or + int remove_call_out(function id); DESCRIPTION This function finds the first call to the function f in the call out queue and removes it. The time left to that call out will be returned. If no call out was found, zero_type(remove_call_out(f)) - will return 1. + will return 1. You can also give a call out id as argument. (as + returned by call_out) SEE ALSO call_out_info, call_out, find_call_out