List of usage examples for java.util.concurrent.locks Lock lock
lock
From source file:net.myrrix.online.ServerRecommender.java
@Override public FastIDSet getUserCluster(int n) throws NotReadyException { Generation generation = getCurrentGeneration(); List<IDCluster> clusters = generation.getUserClusters(); if (clusters == null || clusters.isEmpty()) { throw new UnsupportedOperationException(); }/*w w w .ja v a 2 s . c o m*/ Lock lock = generation.getUserClustersLock().readLock(); FastIDSet members; lock.lock(); try { members = clusters.get(n).getMembers(); } finally { lock.unlock(); } synchronized (members) { return members.clone(); } }
From source file:net.myrrix.online.ServerRecommender.java
@Override public FastIDSet getItemCluster(int n) throws NotReadyException { Generation generation = getCurrentGeneration(); List<IDCluster> clusters = generation.getItemClusters(); if (clusters == null || clusters.isEmpty()) { throw new UnsupportedOperationException(); }// www . j av a 2 s .co m Lock lock = generation.getItemClustersLock().readLock(); FastIDSet members; lock.lock(); try { members = clusters.get(n).getMembers(); } finally { lock.unlock(); } synchronized (members) { return members.clone(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public ExamInfo getInfo(long examId) { Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {/*from w w w. java 2 s .c o m*/ Exam exam = getExam(examId); return (exam == null ? null : new ExamInfo(exam)); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public ExamAssignment getAssignment(long examId) { Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {/*from w w w . j a va 2 s. com*/ Exam exam = getExam(examId); ExamPlacement placement = (exam == null ? null : currentSolution().getAssignment().getValue(exam)); return placement == null ? null : new ExamAssignment(placement, currentSolution().getAssignment()); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public ExamAssignmentInfo getAssignmentInfo(long examId) { Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {//from ww w. j ava2 s . c o m Exam exam = getExam(examId); ExamPlacement placement = (exam == null ? null : currentSolution().getAssignment().getValue(exam)); return placement == null ? null : new ExamAssignmentInfo(placement, currentSolution().getAssignment()); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public Map<String, String> currentSolutionInfo() { if (isPassivated()) return iCurrentSolutionInfoBeforePassivation; Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {/*from w ww. j a v a2 s . c o m*/ return super.currentSolution().getInfo(); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public Map<String, String> bestSolutionInfo() { if (isPassivated()) return iBestSolutionInfoBeforePassivation; Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {/*from w ww. j ava2s . c om*/ return super.currentSolution().getBestInfo(); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public Exam getExam(long examId) { Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {//from w w w . j ava2 s.co m for (Exam exam : currentSolution().getModel().variables()) { if (exam.getId() == examId) return exam; } return null; } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public void clear() { Lock lock = currentSolution().getLock().writeLock(); lock.lock(); try {/* w w w .ja v a2s .c o m*/ for (Exam exam : currentSolution().getModel().variables()) { currentSolution().getAssignment().unassign(0, exam); } currentSolution().clearBest(); } finally { lock.unlock(); } }
From source file:org.unitime.timetable.solver.exam.ExamSolver.java
public Collection<ExamAssignmentInfo> getAssignedExams() { Lock lock = currentSolution().getLock().readLock(); lock.lock(); try {// w w w . j a v a 2s . c o m Vector<ExamAssignmentInfo> ret = new Vector<ExamAssignmentInfo>(); for (Exam exam : currentSolution().getModel().variables()) { ExamPlacement placement = currentSolution().getAssignment().getValue(exam); if (placement != null) ret.add(new ExamAssignmentInfo(placement, currentSolution().getAssignment())); } return ret; } finally { lock.unlock(); } }