while (true) {
synchronized (tuplespaceEx) {
// Look for sub patterns (may be speedup)
if (tuplespaceEx.contains(pattern)) {
LindaArgs result = new LindaArgs(pattern);
pattern.applyResult(result);
if (remove) {
tuplespaceEx.remove(pattern);
}
return true;
}
// More general search
for (Iterator<LindaArgs> iterator = tuplespaceEx.iterator(); iterator.hasNext();) {
LindaArgs tuple = iterator.next();
if (tuple.matchTuples(pattern)) {
LindaArgs result = new LindaArgs(tuple);
pattern.applyResult(result);
if (remove) {
iterator.remove();
}
return true;