[Turn off line numbering]
1: arg time, method, sender, caller, flags, @args;
2: var task, i, j, tid, x, y, tmpq, task_time;
3:
4: // use `@info $scheduler' for more information.
5: // [tid, time, time(), sender(), caller(), method, flags, args]
6: //
7: if (!$sys.is_agent(sender()))
8: throw(~perm, "Sender is not an agent or admin, use .add_task()");
9: if (type(time) != 'integer || type(method) != 'symbol || type(args) != 'list)
10: throw(~type, "Arguments are not an integer, symbol, and list.");
11: if (time < 1)
12: throw(~time, "Time is negative.");
13: if (time > 31536000)
14: throw(~time, "Try to schedule a task LESS than a year from now?");
15: if (!valid(sender))
16: throw(~type, "The argument for sender is not a valid object");
17: if (!valid(caller))
18: throw(~type, "The argument for caller is not a valid object");
19: if (type(flags) != 'list)
20: throw(~type, "Send flags as a list of symbols");
21:
22: //
23: ++task_index;
24: tid = task_index;
25: task_time = time();
26:
27: // flags can be set in a system only add_task, for now set them as 'system
28: task = [tid, task_time + time, task_time, sender, caller, method, flags, args];
29: .add_to_task_queue(task);
30: return tid;
// Miroslav Silovic
// Created 05-Sep-1995 as a part of ColdCore, see: @help Credit