use of lucee.commons.lock.LockInterruptedException in project Lucee by lucee.
the class RWWrap method lock.
public Lock lock(K token, long timeout, boolean readOnly) throws LockException, LockInterruptedException {
if (timeout <= 0)
throw new LockException("timeout must be a postive number");
RWWrap<K> wrap;
// K token=key;
synchronized (locks) {
RWLock<K> lock;
lock = locks.get(token);
if (lock == null) {
locks.put(token, lock = new RWLock<K>(token));
}
lock.inc();
wrap = new RWWrap<K>(lock, readOnly);
}
try {
wrap.lock(timeout);
} catch (LockException e) {
synchronized (locks) {
wrap.getLock().dec();
}
throw e;
} catch (LockInterruptedException e) {
synchronized (locks) {
wrap.getLock().dec();
}
throw e;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
synchronized (locks) {
wrap.getLock().dec();
}
throw new PageRuntimeException(Caster.toPageException(t));
}
return wrap;
}
Aggregations