01: /**
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */package com.tc.util.sequence;
05:
06: public class ObjectIDSequenceProvider implements ObjectIDSequence {
07:
08: private long current;
09:
10: public ObjectIDSequenceProvider(long start) {
11: this .current = start;
12: }
13:
14: public synchronized long nextObjectIDBatch(int batchSize) {
15: final long start = current;
16: current += batchSize;
17: return start;
18: }
19:
20: public void setNextAvailableObjectID(long startID) {
21: if (current > startID) {
22: throw new AssertionError("Current value + " + current
23: + " is greater than " + startID);
24: }
25: current = startID;
26: }
27:
28: }
|