Example usage for java.util.concurrent.locks Lock lock

List of usage examples for java.util.concurrent.locks Lock lock

Introduction

In this page you can find the example usage for java.util.concurrent.locks Lock lock.

Prototype

lock

Source Link

Usage

From source file:org.unitime.timetable.solver.TimetableSolver.java

public String getNotValidReason(Hint hint) {
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {//from  w  w w .  j  a va 2  s.  c  o  m
        return hint.getNotValidReason(this);
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public RoomReport getRoomReport(BitSet sessionDays, int startDayDayOfWeek, Long roomType, Float nrWeeks) {
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {/*from   ww  w .j  av a2 s . co  m*/
        return new RoomReport(this, sessionDays, startDayDayOfWeek, roomType, nrWeeks);
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public DeptBalancingReport getDeptBalancingReport() {
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {//from w ww. j  av a  2  s. c  o  m
        return new DeptBalancingReport(this);
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public Map<String, String> currentSolutionInfo() {
    if (isPassivated())
        return iCurrentSolutionInfoBeforePassivation;
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {// ww  w.j av a  2 s . com
        return super.currentSolution().getExtendedInfo();
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public Suggestions getSuggestions(SuggestionsModel model) {
    if (iWorking)
        return null;
    Lock lock = currentSolution().getLock().writeLock();
    lock.lock();
    try {/*from  www  . java 2  s  .c o  m*/
        return new Suggestions(this, model);
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public Vector getAssignedClasses() {
    Vector ret = new Vector();
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {/*from   w  w  w .  j av  a  2 s. c o  m*/
        for (Lecture lecture : currentSolution().getAssignment().assignedVariables()) {
            ret.addElement(new ClassAssignmentDetails(this, lecture, false));
        }
    } finally {
        lock.unlock();
    }
    return ret;
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public ClassAssignmentDetails getClassAssignmentDetails(Long classId, boolean includeConstraints) {
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {/*from  w  ww .  j av a 2  s  .  c o  m*/
        TimetableModel model = (TimetableModel) currentSolution().getModel();
        for (Lecture lecture : model.variables()) {
            if (lecture.getClassId().equals(classId))
                return new ClassAssignmentDetails(this, lecture, includeConstraints);
        }
        return null;
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public Vector getAssignedClasses(String prefix) {
    Vector ret = new Vector();
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {/*  w w  w .j  a v a 2 s . co  m*/
        for (Lecture lecture : currentSolution().getAssignment().assignedVariables()) {
            if (prefix == null || lecture.getName().startsWith(prefix))
                ret.addElement(new ClassAssignmentDetails(this, lecture, false));
        }
    } finally {
        lock.unlock();
    }
    return ret;
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public AssignmentPreferenceInfo getAssignmentInfo(Long classId) {
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {/*from  www .  java2s  .  c o m*/
        Lecture lecture = null;
        for (Lecture l : currentSolution().getModel().variables()) {
            if (l.getClassId().equals(classId)) {
                lecture = l;
                break;
            }
        }
        if (lecture == null)
            return null;
        Placement placement = (Placement) currentSolution().getAssignment().getValue(lecture);
        if (placement == null)
            return null;
        return new AssignmentPreferenceInfo(this, placement);
    } finally {
        lock.unlock();
    }
}

From source file:org.unitime.timetable.solver.TimetableSolver.java

public PropertiesInfo getGlobalInfo() {
    if (isPassivated())
        return iGlobalInfoBeforePassivation;
    Map<String, String> info = null;
    Lock lock = currentSolution().getLock().readLock();
    lock.lock();
    try {//from w  ww  . j av  a2 s  .c om
        info = super.currentSolution().getBestInfo();
        if (info == null)
            info = super.currentSolution().getInfo();
    } finally {
        lock.unlock();
    }
    PropertiesInfo globalInfo = new PropertiesInfo();
    for (Iterator i1 = info.entrySet().iterator(); i1.hasNext();) {
        Map.Entry entry = (Map.Entry) i1.next();
        String key = (String) entry.getKey();
        String value = entry.getValue().toString();
        globalInfo.setProperty(key, value);
    }
    return globalInfo;
}