1 8 9 package com.sleepycat.je.txn; 10 11 import com.sleepycat.je.DatabaseException; 12 import com.sleepycat.je.dbi.EnvironmentImpl; 13 14 19 public class ThreadLocker extends BasicLocker { 20 21 24 public ThreadLocker(EnvironmentImpl env) 25 throws DatabaseException { 26 27 super(env); 28 } 29 30 33 protected void checkState(boolean ignoreCalledByAbort) 34 throws DatabaseException { 35 36 if (thread != Thread.currentThread()) { 37 throw new DatabaseException("A per-thread transaction was" + 38 " created in " + thread + 39 " but used in " + 40 Thread.currentThread()); 41 } 42 } 43 44 48 public Locker newNonTxnLocker() 49 throws DatabaseException { 50 51 checkState(false); 52 return new ThreadLocker(envImpl); 53 } 54 55 60 public boolean sharesLocksWith(Locker other) { 61 62 if (super.sharesLocksWith(other)) { 63 return true; 64 } else if (other instanceof ThreadLocker) { 65 return thread == ((ThreadLocker) other).thread; 66 } else { 67 return false; 68 } 69 } 70 } 71 | Popular Tags |