future_fork (const qthread_f *f, const void *arg, aligned_t *ret);
The first argument is a pointer to the qthread creating the future computation. This may be a NULL pointer if futures are created by a non-qthread. The second argument, f, is a function that will be run to completion by the created qthread. The last argument, arg, is an argument that will be passed to the specified function.
The qthread_f function must have a prototype like this:
void function(void *arg);
Threads which are spawned with future_fork() must call future_exit() as the final action of the thread in order to free memory and yield up status as an active thread.
When a thread creates future computations, the action may block, waiting for the number of active threads to drop. Deadlock may result if many active threads try to create futures. Therefore, when a thread attempts to create futures, it must explicitly declare itself inactive using the future_yield() function, then reactivate itself using the future_acquire() function.
The typical sequence for creating futures is:
2) loop creating futures
3) [optional: join with futures]
Table of Contents