Method code for $scheduler.add_task()

[Turn on line numbering]
arg time, method, @args;
var task, i, j, tid, flags, x, y, task_time;

if (type(time) != 'integer || type(method) != 'symbol || type(args) != 'list)
    throw(~type, "Arguments are not an integer, symbol, and list.");
if (time < 0)
    throw(~time, "Time is negative.");
if (time > 31536000)
    throw(~time, "Try to schedule a task LESS than a year from now?");

// get a new db task id
++task_index;
tid = task_index;

// flags can be set in a system only add_task, for now set them as 'system
flags = ['system];
task_time = time();
task = [tid, time + task_time, task_time, sender(), caller(), method, flags, args];
.add_to_task_queue(task);
return tid;

// Miroslav Silovic
// Created 05-Sep-1995 as a part of ColdCore, see: @help Credit

Tlon