qt_team_eureka - Man Page

signals a eureka moment

Synopsis

#include <qthread.h>

void
qt_team_eureka (void);

Description

This function signals that the task has reached a eureka moment. As a consequence, all other tasks within the calling task's team and all tasks within subteams whose ancestor tree includes the calling task's team will be preemptively destroyed. The calling task will remain alive as the only task within the team. Its return value location will change to the return value location of the original task of the team (i.e. this task is now treated as the founding task of the team).

An example of how this could be used to search a large binomial tree is as follows:

int target;
node_t *search_inner(node_t *root) {

if (root->value == target) {

qt_team_eureka();
return n;

} else {

qthread_fork(search_inner, root->leftchild, NULL);
qthread_fork(search_inner, root->rightchild, NULL);

}

}

node_t *search(node_t *root) {

node_t *found;
qthread_fork_new_subteam(search_inner, root, &found);
qthread_readFF(NULL, &found);
return found;

}

See Also

qt_team_critical_section(3)

Referenced By

qt_team_critical_section(3).

NOVEMBER 2012 libqthread