silc_schedule_init

SYNOPSIS

    SilcSchedule silc_schedule_init(int max_tasks, void *app_context,
                                    SilcStack stack, SilcSchedule parent);

DESCRIPTION

Initializes the scheduler. This returns the scheduler context or NULL on error. The `app_context' is application specific context that is delivered to all task callbacks. The caller must free that context.

The `max_tasks' is the maximum number of file descriptor and socket tasks in the scheduler. Set value to 0 to use default. Operating system will enforce the final limit. On some operating systems the limit can be significantly increased when this function is called in priviliged mode (as super user).

If `parent' is non-NULL it will be the parent of the new scheduler. If it is NULL this will create a new parent scheduler. If `parent' is already a child scheduler, this will create a new child to the child's parent. Even if `parent' is non-NULL the new child scheduler is still independent scheduler and will run independently of its parent. However, each child and parent will share event tasks added with silc_schedule_task_add_event.

If `stack' is non-NULL all memory allocation for the scheduler is done from the `stack'. Scheduler's stack may be retrieved by calling silc_schedule_get_stack. A stack is created for scheduler always even if `stack' is NULL. If it is non-NULL the created stack is a child stack using `stack' as its parent. This means that memory allocated by the scheduler will be returned to the `stack' when scheduler is destroyed.