com.davfx.ninio.common.QueueCloseableByteBufferHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ninio Show documentation
Show all versions of ninio Show documentation
A Java NIO HTTP client/server as light as possible
package com.davfx.ninio.common;
import java.io.IOException;
import java.nio.ByteBuffer;
public final class QueueCloseableByteBufferHandler implements FailableCloseableByteBufferHandler {
private final Queue queue;
private final CloseableByteBufferHandler wrappee;
public QueueCloseableByteBufferHandler(Queue queue, CloseableByteBufferHandler wrappee) {
this.queue = queue;
this.wrappee = wrappee;
}
@Override
public void handle(final Address address, final ByteBuffer buffer) {
queue.post(new Runnable() {
@Override
public void run() {
wrappee.handle(address, buffer);
}
});
}
@Override
public void close() {
queue.post(new Runnable() {
@Override
public void run() {
wrappee.close();
}
});
}
@Override
public void failed(IOException e) {
close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy