/** * Deregisters a reaction. * * @param r The reaction to register. * @return true if successful, false otherwise. */ public boolean deregisterReaction(Reaction r) { for (int i = 0; i < reactions.size(); i++) { RegisteredReaction rxn = (RegisteredReaction) reactions.get(i); if (rxn.rxn.equals(r)) { reactions.remove(i); return true; } } return false; }
public Tuple inp(Tuple template) { for (int i = 0; i < ts.size(); i++) { Tuple tuple = (Tuple) ts.get(i); log("INP: Comparing:\n" + template + "\nwith:\n" + tuple); if (template.matches(tuple)) { log("INP: Match!"); ts.remove(i); return tuple; } } return null; }
private MessageJ waitForResponse() { synchronized (response) { while (response.size() == 0) { try { response.wait(); } catch (Exception e) { e.printStackTrace(); } } } if (response.size() > 0) { return (MessageJ) response.remove(0); } else { log("BUG: Recursive call to waitForResponse()..."); return waitForResponse(); } }