📄 exclusivelock.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: ExclusiveLock.java,v 1.5 2000/10/28 16:55:16 daniela Exp $package org.ozoneDB.core;import java.io.*;import org.ozoneDB.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.util.*;/** * This class implements an exclusive lock policy. Only one transaction can hold * this lock at one time. * * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.5 $Date: 2000/10/28 16:55:16 $ */public final class ExclusiveLock extends AbstractLock { protected final static long serialVersionUID = 1; protected final static byte subSerialVersionUID = 1; private int level = LEVEL_NONE; /** * ID of the Transaction that holds this lock or null. */ public TransactionID locker; public ExclusiveLock() { reset(); } public synchronized void reset() { level = LEVEL_NONE; locker = null; } public synchronized int tryAcquire( Transaction ta, int newLevel ) { if (ta.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { ta.env.logWriter.newEntry( this, "tryAcquire(): current:" + level + " new:" + newLevel, LogWriter.DEBUG3 ); } int prevLevel = level( ta ); if (locker == null || isAcquiredBy( ta )) { locker = ta.taID(); level = newLevel > level ? newLevel : level; return prevLevel; } else { return NOT_ACQUIRED; } } public synchronized void release( Transaction ta ) { if (ta.env.logWriter.hasTarget( LogWriter.DEBUG3 )) { ta.env.logWriter.newEntry( this, "release()", LogWriter.DEBUG3 ); } if (!isAcquiredBy( ta )) { ta.env.logWriter.newEntry( this, "release(): specified transaction has not aquired lock.", LogWriter.WARN ); } locker = null; level = LEVEL_NONE; } public boolean isAcquiredBy( Transaction ta ) { return locker != null ? locker.equals( ta.taID() ) : false; } public DxCollection lockerIDs() { DxBag result = new DxArrayBag(); if (locker != null) { result.add( locker ); } return result; } public int level( Transaction ta ) { if (ta != null) { return isAcquiredBy( ta ) ? level : LEVEL_NONE; } else { return level; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -