⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singlepool.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if (ls == null)			return;		ls.unlockGroup(lockTable, group, key);	}	/**		Transfer a set of locks from one group to another.  		<BR>		MT - thread safe		@see LockFactory#transfer	*/	public void transfer(Object compatabilitySpace, Object oldGroup, Object newGroup) {		if (SanityManager.DEBUG) {			if (SanityManager.DEBUG_ON(Constants.LOCK_TRACE)) {				StringBuffer sb = new StringBuffer("Lock Transfer:");				D_LockControl.debugAppendObject(                    sb, " CompatabilitySpace=", compatabilitySpace);				D_LockControl.debugAppendObject(sb, " Old Group=", oldGroup);				D_LockControl.debugAppendObject(sb, " New Group=", newGroup);				D_LockControl.debugAddThreadInfo(sb);				SanityManager.DEBUG(Constants.LOCK_TRACE, sb.toString());			}		}		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)			return;		// there is a window where someone could remove the LockSpace from the        // spaces Hashtable, since we do not hold the spaces' monitor. This is        // Ok as the LockSpace will have no locks and this method         // will correctly do nothing.		ls.transfer(oldGroup, newGroup);	}	/**		Returns true if locks by anyone are blocking anyone else	*/	public boolean anyoneBlocked() {		return lockTable.anyoneBlocked();	}	/**		Return true if locks are held in this group and this space.		<BR>		MT - thread safe		@param group handle of group that objects were locked with.		@see LockFactory#areLocksHeld	*/	public boolean areLocksHeld(Object compatabilitySpace, Object group) {		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)			return false;		// there is a window where someone could remove the LockSpace from the         // spaces Hashtable, since we do not hold the spaces' monitor. This is         // Ok as the LockSpace will have no locks and this method will         // correctly return false.		return ls.areLocksHeld(group);	}	/**		Return true if locks are held in this space				<BR>		MT - thread safe		@see LockFactory#areLocksHeld	*/	public boolean areLocksHeld(Object compatabilitySpace) {		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)			return false;		return !ls.isEmpty();	}	public boolean zeroDurationlockObject(Object compatabilitySpace, Lockable ref, Object qualifier, int timeout)		throws StandardException {		if (SanityManager.DEBUG) {			if (SanityManager.DEBUG_ON(Constants.LOCK_TRACE)) {				D_LockControl.debugLock("Zero Duration Lock Request before Grant: ",                     compatabilitySpace, (Object) null, ref, qualifier, timeout);                if (SanityManager.DEBUG_ON(Constants.LOCK_STACK_TRACE))                {                    // The following will print the stack trace of the lock                    // request to the log.                      Throwable t = new Throwable();                   java.io.PrintWriter istream = SanityManager.GET_DEBUG_STREAM();                    istream.println("Stack trace of lock request:");                    t.printStackTrace(istream);                }			}		}		// Very fast zeroDurationlockObject() for unlocked objects.		// If no entry exists in the lock manager for this reference		// then it must be unlocked.		// If the object is locked then we perform a grantable		// check, skipping over any waiters.		// If the caller wants to wait and the lock cannot		// be granted then we do the slow join the queue and		// release the lock method.		synchronized (lockTable) {			Control control = (Control) lockTable.get(ref);			if (control == null) {				return true;			}			// If we are grantable, ignoring waiting locks then			// we can also grant this request now, as skipping			// over the waiters won't block them as we release			// the lock rightway.			if (control.isGrantable(true, compatabilitySpace, qualifier))				return true;			// can't be granted and are not willing to wait.			if (timeout == C_LockFactory.NO_WAIT)				return false;		}		Lock lock =             lockTable.lockObject(compatabilitySpace, ref, qualifier, timeout, (Latch) null);		if (SanityManager.DEBUG) {			if (SanityManager.DEBUG_ON(Constants.LOCK_TRACE)) {				D_LockControl.debugLock(                    "Zero Lock Request Granted: ",                     compatabilitySpace, (Object) null, ref, qualifier, timeout);			}		}		// and simply unlock it once		lockTable.unlock(lock, 1);		return true;	}	public boolean isLockHeld(Object compatabilitySpace, Object group, Lockable ref, Object qualifier) {		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)			return false;		return ls.isLockHeld(group, ref, qualifier);	}	public synchronized void setLimit(Object compatabilitySpace, Object group, int limit, Limit callback) {		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)	{			 ls = new LockSpace(this, compatabilitySpace);			 put(compatabilitySpace, ls);		}		ls.setLimit(group, limit, callback);			}	/**		Clear a limit set by setLimit.	*/	public void clearLimit(Object compatabilitySpace, Object group) {		LockSpace ls = (LockSpace) get(compatabilitySpace);		if (ls == null)			return;		ls.clearLimit(group);	}//EXCLUDE-START-lockdiag- 	/**		Routines to support lock diagnostics VTIs for the benefit of VirtualLockTable	 */	/* package */	public Enumeration makeVirtualLockTable()	{		// make a shallow copy of the locktable.		LockTableVTI myclone = new LockTableVTI(lockTable.shallowClone());		return myclone;	}//EXCLUDE-END-lockdiag- 	/*	** Non-public methods	*///EXCLUDE-START-debug-     public String toDebugString()    {        return(lockTable.toDebugString());    }//EXCLUDE-END-debug- 		/*	** Methods of PropertySetCallback	*/	public void init(boolean dbOnly, Dictionary p) {		getAndApply(dbOnly, p, Property.DEADLOCK_TIMEOUT);		getAndApply(dbOnly, p, Property.LOCKWAIT_TIMEOUT);		getAndApply(dbOnly, p, Property.DEADLOCK_MONITOR);//EXCLUDE-START-lockdiag-         getAndApply(dbOnly, p, Property.DEADLOCK_TRACE);//EXCLUDE-END-lockdiag- 	}	private void getAndApply(boolean dbOnly, Dictionary p, String key) {		try {			Serializable value = (String) PropertyUtil.getPropertyFromSet(dbOnly, p, key);			if (value != null) {				validate(key, value, p);				apply(key, value, p);			}		} catch (StandardException se) {			// just ignore value at bootup.		}	}		public boolean validate(String key, Serializable value, Dictionary p)		throws StandardException {		if (!key.startsWith(Property.LOCKS_INTRO))			return false;		if (value != null) {			if (key.equals(Property.DEADLOCK_TIMEOUT))				getWaitValue((String) value,  Property.DEADLOCK_TIMEOUT_DEFAULT);			else if (key.equals(Property.LOCKWAIT_TIMEOUT))				getWaitValue((String) value,  Property.WAIT_TIMEOUT_DEFAULT);			else if (key.equals(Property.DEADLOCK_MONITOR))				PropertyUtil.booleanProperty(Property.DEADLOCK_MONITOR, value, false);            else if (key.equals(Property.DEADLOCK_TRACE))                PropertyUtil.booleanProperty(Property.DEADLOCK_TRACE, value, false);		}		return true;	}    public Serviceable apply(String key, Serializable value, Dictionary p)		throws StandardException {		if (value == null) {			// a delete, fill in the new value			value = PropertyUtil.getPropertyFromSet(p, key);		}		String svalue = (String) value;		if (key.equals(Property.DEADLOCK_TIMEOUT))			lockTable.deadlockTimeout = getWaitValue(svalue,  Property.DEADLOCK_TIMEOUT_DEFAULT);		else if (key.equals(Property.LOCKWAIT_TIMEOUT))			lockTable.waitTimeout = getWaitValue(svalue,  Property.WAIT_TIMEOUT_DEFAULT);		else if (key.equals(Property.DEADLOCK_MONITOR)) {			deadlockMonitor = PropertyUtil.booleanProperty(Property.DEADLOCK_MONITOR, svalue, false) ?				StandardException.REPORT_ALWAYS : StandardException.REPORT_DEFAULT;		}//EXCLUDE-START-lockdiag-         else if (key.equals(Property.DEADLOCK_TRACE))            lockTable.setDeadlockTrace(PropertyUtil.booleanProperty(Property.DEADLOCK_TRACE, svalue, false));//EXCLUDE-END-lockdiag- 		return null;	}	    public Serializable map(String key, Serializable value, Dictionary p) {		return null;	}	/*	** Property related methods	*/		private static int getWaitValue(String value, int defaultValue ) {		// properties are defined in seconds		int wait = PropertyUtil.handleInt(value, Integer.MIN_VALUE, Integer.MAX_VALUE / 1000, defaultValue);		if (wait < 0)			wait = C_LockFactory.WAIT_FOREVER;		else			// convert to milliseconds			wait *= 1000;		return wait;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -