ft_thread_generate,(1)

NAME
ft_thread_generate, ft_thread_await - generate and await an event

  SYNOPSIS

#include <fthread.h>
int ft_thread_generate       (ft_event_t evt);
int ft_thread_generate_value (ft_event_t evt,void *val);
int ft_thread_await          (ft_event_t evt);
int ft_thread_await_n        (ft_event_t evt,int n);
int ft_thread_select         (int len,ft_event_t *array,int *mask);
int ft_thread_select_n       (int len,ft_event_t *array,int *mask,int timeout);

  DESCRIPTION
ft_thread_generate generates the event evt for the current instant of the scheduler in which the calling thread is running. The event is thus present for this instant; it will be automatically reset to absent at the begining of the next instant. The value val is associated to evt when ft_thread_generate_value is used.

ft_thread_await suspends the calling thread until evt becomes generated in the scheduler in which it is running. The waiting takes as many instants as the generation of evt takes. ft_thread_await_n (evt,k) is similar to ft_thread_await (evt) except that the waiting of evt lasts at most k instants.

 ft_thread_select suspends the calling thread until one element of array becomes generated in the scheduler in which the thread is running; array should be of length k. On resumption, mask which is an array of k integers, is set accordingly: mask[i] is 1 if array[i] was generated; mask[i] is 0, otherwise. ft_thread_select_n (k,array,mask,p) is similar to ft_thread_select (k,array,mask) except that the waiting lasts at most p instants.

  RETURN VALUES
On success the value 0 is returned and a non-zero error code is returned on error.

  ERRORS

    BADCREATE
        The exist an event (either evt or an element of array) which is not correctly created.

    BADLINK
        Either the calling thread is unlinked, or the scheduler of the calling thread and the one of a considered event (evt or an element of array) are different.

    BADMEM
        Not enough memory (can only occur with ft_thread_generate_value).

    TIMEOUT
        The timeout is reached.

  SEE ALSO
ft_event_create (3), ft_thread_get_value (3).

AUTHOR