/** * Simulated check. * * @param g estimated graph, not loaded from XML. * @param question question loaded from XML or computed by a learner. * @param responseForNoRestart ignored. * @param lengthInHardFacts ignored. * @param options set to null by the simulator. * @return value loaded from XML or computed by the learner. */ @Override public synchronized Pair<Integer, String> CheckWithEndUser( LearnerGraph graph, List<Label> argQuestion, int responseForNoRestart, List<Boolean> acceptedElements, PairScore pairBeingMerged, Object[] options) { Pair<Integer, String> result = null; // First, we call the expected method if (Thread.currentThread() == secondThread) { result = whatToCompareWith.CheckWithEndUser( graph, argQuestion, responseForNoRestart, acceptedElements, pairBeingMerged, options); question = argQuestion; cPair = result; } else result = decoratedLearner.CheckWithEndUser( graph, argQuestion, responseForNoRestart, acceptedElements, pairBeingMerged, options); syncOnCallOf(KIND_OF_METHOD.M_CHECKWITHUSER); if (Thread.currentThread() != secondThread) { // checking. if (!question.equals(argQuestion)) failureCode = new IllegalArgumentException("different CheckWithEndUser questions"); if (!cPair.equals(result)) failureCode = new IllegalArgumentException( "different CheckWithEndUser results " + cPair.firstElem + " v.s. " + result.firstElem + " and " + cPair.secondElem + " v.s. " + result.secondElem); cPair = null; question = null; // reset stored data } syncOnCallOf(KIND_OF_METHOD.M_METHODEXIT); // aims to stop one of the threads running fast // from the first checkCall and overwriting the stored value before the other // thread had a chance to use it in a comparison. return result; }