Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int su_clone_start ( su_root_t parent,
su_clone_r  return_clone,
su_root_magic_t magic,
su_root_init_f  init,
su_root_deinit_f  deinit 

Start a clone task.

Allocate and initialize a sub-task. Depending on the su_root_threading() settings, a separate thread may be created to execute the sub-task. The sub-task is represented by clone handle to the rest of the application. The function su_clone_start() returns the clone handle in return_clone. The clone handle is used to communicate with the newly created clone task using messages.

A new su_root_t object is created for the sub-task with the magic as the root context pointer. Because the sub-task may or may not have its own thread, all its activity must be scheduled via this root object. In other words, the sub-task can be schedule

  1. I/O events with su_root_register()
  2. timers with su_timer_set(), su_timer_set_at() or su_timer_run()
  3. messages with su_msg_send().

Messages can also be used to pass information between tasks or threads.

In multi-threaded implementation, su_clone_start() launches a new thread, and the initialization routine is executed by this newly created thread. The calling thread blocks until the initialization routine completes. If the initialization routine returns su_success (0), the sub-task is considered to be created successfully. After the successful initialization, the sub-task continues to execeute the function su_root_run().

In single-threaded implementations, just a new root object is created. The initialization routine is called directly from su_clone_start().

If the initalization function init fails, the sub-task (either the newly created thread or the current thread executing the su_clone_start() function) calls the deinitialization function, and su_clone_start() returns NULL.

parentroot to be cloned
return_clonereference to a clone [OUT]
magicpointer to user data
initinitialization function
deinitdeinitialization function
0 if successfull, -1 upon an error.
Earlier documentation mentioned that parent could be NULL. That feature has never been implemented, however.
See also:
su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(), su_clone_forget().

Definition at line 288 of file su_port.c.

References su_clone_start(), and su_seterrno().

Referenced by nua_create(), su_clone_start(), and su_root_clone().

  su_port_vtable_t const *svp;

  if (init == NULL)
    init = su_root_init_nothing;
  if (deinit == NULL)
    deinit = su_root_deinit_nothing;

  if (parent == NULL || parent->sur_threading) {
    if (preferred_su_clone_start == NULL)
    return preferred_su_clone_start(parent, return_clone, magic, init, deinit);

  svp = parent->sur_task->sut_port->sup_vtable;

  if (svp->su_port_start_shared == NULL)
    return su_seterrno(EINVAL);

  /* Return a task sharing the same port. */
  return svp->su_port_start_shared(parent, return_clone, magic, init, deinit);

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index