ft_thread_create(1)

NAME
ft_thread_create - create a new thread

  SYNOPSIS

#include <fthread.h>
ft_thread_t ft_thread_create (ft_scheduler_t sched,
                              void (*runnable)(void*),
                              void (*cleanup)(void*),
                              void *args);

  DESCRIPTION

ft_thread_create returns a new thread of control and links it to the scheduler sched. While linked in sched, the new thread will execute concurrently with the other threads linked in it. Actual starting of the new thread is asynchronous with the creation. The new thread applies the function runnable passing it args as first argument. The new thread terminates when it executes ft_exit or when it returns from the runnable function.

When stopped (by ft_scheduler_stop), the new thread applies the function cleanup, if it is not NULL, passing it args as first argument.

 A pthread is created with each fair thread. This pthread is initially attached. It can be detached using ft_pthread and pthread_detach.

  RETURN VALUES
On success, ft_thread_create returns a new thread; NULL is returned otherwise.

  ERRORS

    NULL
        The thread cannot be created, or the scheduler sched is not correctly created.

  SEE ALSO
ft_exit (3), ft_scheduler_create (3), ft_scheduler_stop (3), ft_pthread (3).

AUTHOR