Hibernation
This commit is contained in:
parent
a359656ca9
commit
09519997dc
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<groupId>it.cavallium</groupId>
|
<groupId>it.cavallium</groupId>
|
||||||
<artifactId>filequeue</artifactId>
|
<artifactId>filequeue</artifactId>
|
||||||
<name>file queue project</name>
|
<name>file queue project</name>
|
||||||
<version>3.1.6</version>
|
<version>3.1.7</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Light weight, high performance, simple, reliable and persistent queue</description>
|
<description>Light weight, high performance, simple, reliable and persistent queue</description>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -73,6 +73,10 @@ public class SimpleQueueMemorySegment<T> implements SimpleQueue<T>, Closeable {
|
|||||||
private SimpleQueueMemorySegmentFixedSize expandQueueSegmentForWrite() throws IOException {
|
private SimpleQueueMemorySegmentFixedSize expandQueueSegmentForWrite() throws IOException {
|
||||||
synchronized (queueSegments) {
|
synchronized (queueSegments) {
|
||||||
var queueMemorySegment = new SimpleQueueMemorySegmentFixedSize(arena, segmentSize, generateQueuePath());
|
var queueMemorySegment = new SimpleQueueMemorySegmentFixedSize(arena, segmentSize, generateQueuePath());
|
||||||
|
// Hibernate the middle segments, if there will be 3 or more segments after the expansion
|
||||||
|
if (queueSegments.size() >= 2) {
|
||||||
|
queueSegments.getLast().hibernate();
|
||||||
|
}
|
||||||
queueSegments.add(queueMemorySegment);
|
queueSegments.add(queueMemorySegment);
|
||||||
return queueMemorySegment;
|
return queueMemorySegment;
|
||||||
}
|
}
|
||||||
|
@ -86,4 +86,8 @@ public class SimpleQueueMemorySegmentFixedSize implements Closeable {
|
|||||||
public int size() {
|
public int size() {
|
||||||
return Math.max(0, size.get());
|
return Math.max(0, size.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hibernate() {
|
||||||
|
this.writer.unload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user