1 package org.objectweb.perseus.concurrency.lib; 2 3 4 27 38 public class RWLockValue implements LockValue { 39 40 public static final byte READ = 1; 41 public static final byte UPGRADE = 2; 42 public static final byte WRITE = 3; 43 44 45 53 54 static final byte compTable[] = { 15, 3, 1, 1 }; 55 56 57 public byte maxValue() { 58 return WRITE; 59 } 60 61 public boolean isCompatibleWith(byte l1, byte l2) { 62 boolean res = (((1 << l1) & compTable[l2]) != 0); 63 return res; 64 } 65 66 public byte getCompatibleWith(byte l1, byte l2) { 67 while (!isCompatibleWith(l1, l2)) l1--; 68 return l1; 69 } 70 71 public String str(byte l) { 72 switch(l) { 73 case NOLOCK: return "NOLOCK"; 74 case READ: return "READ"; 75 case UPGRADE: return "UPGRADE"; 76 case WRITE: return "WRITE"; 77 default: return "UNDEFINED"; 78 } 79 } 80 } 81 | Popular Tags |