testSetCharSequenceMultipleThreads() — netty Function Reference
Architecture documentation for the testSetCharSequenceMultipleThreads() function in AbstractByteBufTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 66fdad11_5c58_31af_4b09_4de1b9743ad9["testSetCharSequenceMultipleThreads()"] 6540f2d1_cdad_6705_dd1d_9a24e2e53242["AbstractByteBufTest"] 66fdad11_5c58_31af_4b09_4de1b9743ad9 -->|defined in| 6540f2d1_cdad_6705_dd1d_9a24e2e53242 style 66fdad11_5c58_31af_4b09_4de1b9743ad9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java lines 2953–3011
@SuppressWarnings("unchecked")
@ParameterizedTest
@MethodSource("setCharSequenceCombinations")
void testSetCharSequenceMultipleThreads(final Charset charset, CharSequenceType charSeqType) throws Exception {
int bufSize = 32;
ByteBuf[] bufs = new ByteBuf[16];
for (int i = 0; i < bufs.length; i++) {
bufs[i] = newBuffer(bufSize);
}
int iterations = 256;
Semaphore start = new Semaphore(0);
Semaphore finish = new Semaphore(0);
char[] cs = new char[(int) (bufSize / charset.newEncoder().maxBytesPerChar())];
Arrays.fill(cs, 'a');
final CharSequence str = charSeqType.create(cs);
ExecutorService executor = Executors.newFixedThreadPool(bufs.length);
try {
Future<Void>[] futures = new Future[bufs.length];
for (int i = 0; i < bufs.length; i++) {
final ByteBuf buf = bufs[i];
futures[i] = executor.submit(() -> {
finish.release();
start.acquire();
for (int j = 0; j < iterations; j++) {
buf.setCharSequence(0, str, charset);
}
return null;
});
}
finish.acquire(bufs.length);
start.release(bufs.length);
Exception e = null;
for (Future<Void> future : futures) {
try {
future.get();
} catch (InterruptedException ex) {
if (e != null) {
ex.addSuppressed(e);
}
throw ex; // Propagate interrupted exceptions immediately.
} catch (ExecutionException ex) {
if (e == null) {
e = ex;
} else {
e.addSuppressed(ex);
}
}
}
if (e != null) {
fail("Worker threads failed", e);
}
} finally {
executor.shutdown();
for (ByteBuf buf : bufs) {
buf.release();
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testSetCharSequenceMultipleThreads() do?
testSetCharSequenceMultipleThreads() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java.
Where is testSetCharSequenceMultipleThreads() defined?
testSetCharSequenceMultipleThreads() is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java at line 2953.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free