1 package org.objectweb.perseus.concurrency.lib; 2 3 4 27 public class ReadWriteLockValue implements LockValue { 28 29 public static final byte READ = 1; 30 public static final byte UPGRADE = 2; 31 public static final byte WRITE = 3; 32 33 34 42 43 static final byte compTable[] = { 15, 3, 1, 1 }; 44 45 46 public byte maxValue() { 47 return WRITE; 48 } 49 50 public boolean isCompatibleWith(byte l1, byte l2) { 51 boolean res = (((1 << l1) & compTable[l2]) != 0); 52 return res; 53 } 54 55 public byte getCompatibleWith(byte l1, byte l2) { 56 while (!isCompatibleWith(l1, l2)) l1--; 57 return l1; 58 } 59 60 public String str(byte l) { 61 switch(l) { 62 case NOLOCK: return "NOLOCK"; 63 case READ: return "READ"; 64 case UPGRADE: return "UPGRADE"; 65 case WRITE: return "WRITE"; 66 default: return "UNDEFINED"; 67 } 68 } 69 } 70 | Popular Tags |