void
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. (Note that f is a qthread_f and not a qthread_t.) 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(qthread_t *me, 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:
1) yield
2) loop creating futures
3) [optional: join with futures]
4) acquire