Example #1
0
int hasCycleYields(struct Node* _n) {
	if (_n->nYields == 0) {
		_n->color = 2;
		return false;
	}
	int i = 0;
	while (i < _n->nYields) {
		add(&stack, _n, _n->posYields[i]);
		blocked = false;
		if ((_n->yields[i])->color == 1) {
			if (joinPointFound == NULL) {
				copy(&stack, &cycle);
				joinPointFound = (_n->yields[i]);
			}
			blocked = true;
		} else if ((_n->yields[i])->color == 0) {
			blocked = hasCycles(_n->yields[i]);
		}
		backtrack(&stack);

		if (!blocked) {
			_n->color = 2;
			joinPointFound = NULL;
			return false;
		}
		i = i + 1;
	}
	return true;
}
Example #2
0
bool DecayTree::isDecayTreeValid() const {
  if (hasCycles()) {
    throw std::runtime_error(
        "The decay tree has a cyclic dependency, meaning the tree is corrupted. Please fix the configuration file and rerun!");
  }
  if (isDisconnected()) {
    throw std::runtime_error(
        "The decay tree is not connected, meaning the tree is corrupted. Please fix the configuration file and rerun!");
  }
  return true;
}
Example #3
0
int checkForCycles(struct Node* _t) {
	reset(_t);
	if (hasCycles(_t)) {
		LOGD("deadlock found !");
		struct Template tmpl;
		init_Template(&tmpl);
		getTemplate(&tmpl);
		saveTemplate(&tmpl);
		return true;
	}
	return false;
}
Example #4
0
int hasCycleNext(struct Node* _n) {
	if (_n->type == 1) {
		add(&stack, _n, _n->posNext);
	} else {
		add(&stack, _n, NULL);
	}

	if ((_n->next)->color == 1) {
		if (joinPointFound == NULL) {
			copy(&stack, &cycle);
			joinPointFound = (_n->next);
		}
		blocked = true;
	} else if ((_n->next)->color == 0) {
		blocked = hasCycles(_n->next);
	}
	backtrack(&stack);
	if (blocked) {
		return true;
	} else {
		joinPointFound = NULL;
		return false;
	}
}