Hibernation
This commit is contained in:
parent
a359656ca9
commit
09519997dc
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>filequeue</artifactId>
|
||||
<name>file queue project</name>
|
||||
<version>3.1.6</version>
|
||||
<version>3.1.7</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>Light weight, high performance, simple, reliable and persistent queue</description>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -73,6 +73,10 @@ public class SimpleQueueMemorySegment<T> implements SimpleQueue<T>, Closeable {
|
||||
private SimpleQueueMemorySegmentFixedSize expandQueueSegmentForWrite() throws IOException {
|
||||
synchronized (queueSegments) {
|
||||
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);
|
||||
return queueMemorySegment;
|
||||
}
|
||||
|
@ -86,4 +86,8 @@ public class SimpleQueueMemorySegmentFixedSize implements Closeable {
|
||||
public int size() {
|
||||
return Math.max(0, size.get());
|
||||
}
|
||||
|
||||
public void hibernate() {
|
||||
this.writer.unload();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user