Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/entry/SleeveState.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.entry; | |
2 | |
3 /** | |
4 Each Sleeve held in-cache has a chunk of management state associated with it | |
5 which is maintained in an instance of this class | |
6 */ | |
7 class SleeveState { | |
8 /** | |
9 If set, indicates this Sleeve does not exist on disk. | |
10 i.e. If it needs to be written to disk it should be inserted rather | |
11 than updated (create as opposed to update). | |
12 */ | |
13 static final int NOT_ON_DISK = 1; | |
14 | |
15 /** | |
16 Indicates this Sleeve has been deleted and the space can be reclaimed. | |
17 */ | |
18 static final int DELETED = 2; | |
19 | |
20 /** | |
21 If set, indicates that this Sleeve should not be saved to disk | |
22 | |
23 @see org.dancres.blitz.entry.WriteScheduler | |
24 */ | |
25 static final int PINNED = 4; | |
26 | |
27 private int theFlags; | |
28 | |
29 /** | |
30 Applies the specified state cummulatively to the current state flags. | |
31 i.e. Logical OR | |
32 */ | |
33 synchronized void set(int aFlags) { | |
34 theFlags |= aFlags; | |
35 } | |
36 | |
37 /** | |
38 Replace existing state with that passed in. | |
39 */ | |
40 synchronized void setExplicit(int aFlags) { | |
41 theFlags = aFlags; | |
42 } | |
43 | |
44 synchronized boolean test(int aFlag) { | |
45 return ((theFlags & aFlag) != 0); | |
46 } | |
47 | |
48 synchronized void clear(int aFlag) { | |
49 int myMask = aFlag ^ 0xFFFFFFFF; | |
50 theFlags &= myMask; | |
51 } | |
52 | |
53 synchronized int get() { | |
54 return theFlags; | |
55 } | |
56 | |
57 public synchronized String toString() { | |
58 return Integer.toBinaryString(theFlags); | |
59 } | |
60 } |