protected void disposeLockingSynchronizers() { Map<Object, LockingSynchronizer> lockingSynchronizers = this.lockingSynchronizers; if (lockingSynchronizers != null) { synchronized (lockingSynchronizers) { Collection<LockingSynchronizer> v = lockingSynchronizers.values(); if (v != null) { for (LockingSynchronizer synchronizer : v) { synchronizer.dispose(); } } this.lockingSynchronizers.clear(); this.lockingSynchronizers = null; } } }
protected LockingSynchronizer getLockingSynchronizer(Object entity) { LockingSynchronizer res = null; { if (entity != null) { synchronized (lockingSynchronizers) { res = lockingSynchronizers.get(entity); if (res == null) { TimeModel timeModel = getTimeModel(); res = createLockingSynchronizer(entity, timeModel, lockListener); lockingSynchronizers.put(entity, res); } } } } return res; }
public synchronized void shutdown() { // Shutdown the executing synchronizer: { if (executingSynchronizer != null) { executingSynchronizer.shutdown(); } } // Shutdown the locking synchronizers: { Map<Object, LockingSynchronizer> lockingSynchronizers = this.lockingSynchronizers; if (lockingSynchronizers != null) { synchronized (lockingSynchronizers) { Collection<LockingSynchronizer> v = lockingSynchronizers.values(); if (v != null) { for (LockingSynchronizer synchronizer : v) { synchronizer.shutdown(); } } } } } }
public List<Object> getEntities() { List<Object> res = null; { Set<Object> keySet = null; synchronized (lockingSynchronizers) { keySet = lockingSynchronizers.keySet(); } if (keySet != null) { res = new ArrayList<Object>(); res.addAll(keySet); } } return res; }
public synchronized boolean awaitShutdown(long timeout) throws InterruptedException { boolean res = false; { long t0 = System.currentTimeMillis(); long t1 = t0 + timeout; long timeoutLeft = timeout; // Await shutdown of the executing synchronizer: { if (executingSynchronizer != null) { executingSynchronizer.awaitShutdown(timeoutLeft); } } // Await shutdown of the locking synchronizers: { if (lockingSynchronizers != null) { synchronized (lockingSynchronizers) { Collection<LockingSynchronizer> v = lockingSynchronizers.values(); if (v != null) { for (LockingSynchronizer synchronizer : v) { long t = System.currentTimeMillis(); timeoutLeft = t1 - t; if (timeoutLeft <= 0) { break; } else { synchronizer.awaitShutdown(timeoutLeft); } } } } } } } return res; }
protected void removeEntity(Object entity) { synchronized (lockingSynchronizers) { lockingSynchronizers.remove(entity); } }