taskdied, taskstarted

taskdied, taskstarted — internal functions that call another function when a task starts or stops.

Syntax

taskdied (task_name, qname, domain, node, task_id)
taskstarted (task_name, qname, domain, node, task_id)
		

Arguments

task_name

The name of the task which started or stopped.

node

The node on which the task started or stopped.

task_id

The process ID for the task.

qname

The name of the task's queue, if any.

domain

The Cascade DataHub domain for this task.

Returns

User-defined.

Description

These functions are internal to Gamma. They call run_hooks (#taskstarted_hook, args...) and run_hooks (#taskdied_hook, args...) respectively. They are called whenever a task registered with the Cascade NameServer (nserve) starts or stops. You can set up hooks to use these functions through the add_hook function.

[Note]

These functions were originally available to programmers, and have been internalized to allow for the greater flexibility of the add_hook and run_hook functions. However, if you have existing code that you don't want to change, you can define your own versions of taskdied and taskstarted that shadow the built-in functions and do what they always used to do. Your old code will not break, but it will hide the hook version of the taskdied and taskstarted functions.

On the other hand, you could get both with something like this:

builtin_taskdied = taskdied;
builtin_taskstarted = taskstarted;

function main ()
{
    init_ipc ("x","x");

    add_hook (#taskdied_hook, #hook_taskdied);
    add_hook (#taskstarted_hook, #hook_taskstarted);

    while(t)
        next_event();
}

function taskdied (!a?...=nil)
{
    princ ("task died: ", a, "\n");
    funcall (builtin_taskdied, a);
}

function taskstarted (!a?...=nil)
{
    princ ("task started: ", a, "\n");
    funcall (builtin_taskstarted, a);
}

function hook_taskdied (!a?...=nil)
{
    princ ("hook task died: ", a, "\n");
}

function hook_taskstarted (!a?...=nil)
{
    princ ("hook task started: ", a, "\n");
}