
org.bdware.doip.SemaphoreController Maven / Gradle / Ivy
package org.bdware.doip;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import java.util.concurrent.Semaphore;
public class SemaphoreController extends SimpleChannelInboundHandler {
Semaphore semaphore = new Semaphore(20);
SimpleChannelInboundHandler handler;
public SemaphoreController(SimpleChannelInboundHandler handler) {
this.handler = handler;
}
@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, DoipMessage irpMessage) throws Exception {
semaphore.acquire();
try {
handler.channelRead(channelHandlerContext, irpMessage);
} catch (Exception e) {
e.printStackTrace();
} finally {
semaphore.release();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy