Table of Contents

Name

future_yield - explicitly declare the calling thread inactive

Synopsis

#include <qthread/futurelib.h>

int
future_yield (void);

Description

In order to prevent deadlocks over resource acquisition, threads should make a call to yield before attempting to create or join with futures.

If a thread calls the yield function with an argument which is not a qthread which was created as a future, the yield function do nothing. This is acceptable behavior and it is generally expected that threads will attempt to yield before creating or joining with futures in the chance that yielding is necessary.

The typical sequence for creating futures is:

1) yield
2) loop creating futures
3) [optional: join with futures]
4) acquire

Return Value

future_yield() returns nonzero when the yield resulted in the active future count decreasing, i.e. if the calling thread was a future itself. Otherwise, the function returns zero, i.e. no yield could be performed.

See Also

future_join_all(3) , future_init(3) , future_exit(3) , future_yield(3) , future_acquire(3)


Table of Contents