comparison src/org/dancres/blitz/arc/CacheBlockDescriptor.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.arc;
2
3 import java.util.logging.Level;
4
5 import java.io.Serializable;
6
7 import EDU.oswego.cs.dl.util.concurrent.Mutex;
8
9 import org.dancres.struct.LinkedInstance;
10
11 import org.dancres.blitz.cache.Identifiable;
12 import org.dancres.blitz.cache.Identifier;
13 import org.dancres.blitz.cache.CacheListenerSet;
14
15 /**
16 Each object currently in cache is referenced via a CacbeBlockDescriptor
17 */
18 public class CacheBlockDescriptor implements LinkedInstance {
19 private Identifier theIdentifier;
20 private Identifiable theContent;
21
22 private LinkedInstance thePrev;
23 private LinkedInstance theNext;
24
25 private int isWhere;
26
27 private Mutex theLock = new Mutex();
28
29 CacheBlockDescriptor() {
30 }
31
32 void acquire() throws InterruptedException {
33 theLock.acquire();
34 }
35
36 public void release() {
37 theLock.release();
38 }
39
40 public void setId(Identifier anIdentifier) {
41 theIdentifier = anIdentifier;
42 }
43
44 public Identifier getId() {
45 return theIdentifier;
46 }
47
48 public Identifiable getContent() {
49 return theContent;
50 }
51
52 void setContent(Identifiable aContent) {
53 theContent = aContent;
54 }
55
56 public void setNext(LinkedInstance aLinkedInstance) {
57 theNext = aLinkedInstance;
58 }
59
60 public LinkedInstance getNext() {
61 return theNext;
62 }
63
64 public void setPrev(LinkedInstance aLinkedInstance) {
65 thePrev = aLinkedInstance;
66 }
67
68 public LinkedInstance getPrev() {
69 return thePrev;
70 }
71
72 boolean isEmpty() {
73 return (theContent == null);
74 }
75
76 /**
77 Marks the CBD as being on a particular list, T1, T2, B1 or B2.
78
79 @see org.dancres.blitz.arc.Lru
80 */
81 void setWhere(int aWhere) {
82 isWhere = aWhere;
83 }
84
85 /**
86 Returns an indication of which list this CBD is on, T1, T2, B1 or B2.
87
88 @see org.dancres.blitz.arc.Lru
89 */
90 int getWhere() {
91 return isWhere;
92 }
93 }