Skip to content

Commit

Permalink
chore: Use fixed thread pool to perform disk I/O.
Browse files Browse the repository at this point in the history
  • Loading branch information
nstdio committed Jan 7, 2023
1 parent f7574ac commit 6349789
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/github/nstdio/http/ext/DiskCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DiskCache extends SizeConstrainedCache {
this.metadataSerializer = metadataSerializer;
this.streamFactory = streamFactory;
this.dir = dir;
this.executor = Executors.newSingleThreadExecutor(r -> new Thread(r, "disk-cache-io"));
this.executor = Executors.newFixedThreadPool(1, r -> new Thread(r, "disk-cache-io"));

restore();
}
Expand Down
14 changes: 9 additions & 5 deletions src/test/kotlin/io/github/nstdio/http/ext/BuffersTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package io.github.nstdio.http.ext

import io.kotest.matchers.types.shouldBeSameInstanceAs
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.map
import io.kotest.property.arbitrary.next
import org.assertj.core.api.Assertions.assertThat
Expand Down Expand Up @@ -72,12 +71,17 @@ internal class BuffersTest {
fun listBuffersData(): Stream<List<ByteBuffer>> {
return Stream.of(
listOf(),
listOf("abcde".repeat(16).toByteBuffer()),
listOf("abcde".repeat(8).toByteBuffer()),
listOf(
"ab".repeat(16).toByteBuffer(),
"cd".repeat(16).toByteBuffer()
"ab".repeat(8).toByteBuffer(),
"cd".repeat(8).toByteBuffer()
),
Arb.byteArray(Arb.int(96, 96)).next().toChunkedBuffers(true)
listOf(
"ab".repeat(8).toByteBuffer(),
"cd".repeat(8).toByteBuffer(),
"ef".repeat(8).toByteBuffer()
),
Arb.byteArray(96).next().toChunkedBuffers(true)
)
}
}
Expand Down

0 comments on commit 6349789

Please sign in to comment.