slight fill interest cleanup

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-03-16 11:49:33 +01:00 committed by Simone Bordet
parent 9d0b7f71ac
commit 03fd0d5fef
2 changed files with 20 additions and 30 deletions

View File

@ -35,12 +35,14 @@ public class QuicStreamEndPoint extends IdleTimeout implements EndPoint
{
private static final Logger LOG = LoggerFactory.getLogger(QuicStreamEndPoint.class);
private final AtomicBoolean fillable = new AtomicBoolean();
private final FillInterest fillInterest = new FillInterest()
{
@Override
protected void needsFillInterest() throws IOException
{
if (fillable.getAndSet(false))
fillInterest.fillable();
}
};
private final long streamId;
@ -139,14 +141,12 @@ public class QuicStreamEndPoint extends IdleTimeout implements EndPoint
return quicheConnection;
}
//TODO: this is racy
private final AtomicBoolean fillable = new AtomicBoolean();
public Runnable onSelected(InetSocketAddress remoteAddress, boolean readable, boolean writable)
{
this.remoteAddress = remoteAddress;
return () ->
{
//TODO: this is racy
if (!fillInterest.fillable())
fillable.set(true);
};
@ -156,17 +156,12 @@ public class QuicStreamEndPoint extends IdleTimeout implements EndPoint
public void fillInterested(Callback callback) throws ReadPendingException
{
fillInterest.register(callback);
if (fillable.getAndSet(false))
fillInterest.fillable();
}
@Override
public boolean tryFillInterested(Callback callback)
{
boolean registered = fillInterest.tryRegister(callback);
if (registered && fillable.getAndSet(false))
fillInterest.fillable();
return registered;
return fillInterest.tryRegister(callback);
}
@Override

View File

@ -40,12 +40,14 @@ public class ServerDatagramEndPoint extends IdleTimeout implements EndPoint, Man
{
private static final Logger LOG = LoggerFactory.getLogger(ServerDatagramEndPoint.class);
private final AtomicBoolean fillable = new AtomicBoolean();
private final FillInterest fillInterest = new FillInterest()
{
@Override
protected void needsFillInterest() throws IOException
{
if (fillable.getAndSet(false))
fillInterest.fillable();
}
};
private final DatagramChannel channel;
@ -166,19 +168,6 @@ public class ServerDatagramEndPoint extends IdleTimeout implements EndPoint, Man
LOG.info("idle timeout", timeout);
}
//TODO: this is racy
private final AtomicBoolean fillable = new AtomicBoolean();
@Override
public Runnable onSelected()
{
return () ->
{
if (!fillInterest.fillable())
fillable.set(true);
};
}
@Override
public void updateKey()
{
@ -191,21 +180,27 @@ public class ServerDatagramEndPoint extends IdleTimeout implements EndPoint, Man
throw new UnsupportedOperationException();
}
@Override
public Runnable onSelected()
{
return () ->
{
//TODO: this is racy
if (!fillInterest.fillable())
fillable.set(true);
};
}
@Override
public void fillInterested(Callback callback) throws ReadPendingException
{
fillInterest.register(callback);
if (fillable.getAndSet(false))
fillInterest.fillable();
}
@Override
public boolean tryFillInterested(Callback callback)
{
boolean registered = fillInterest.tryRegister(callback);
if (registered && fillable.getAndSet(false))
fillInterest.fillable();
return registered;
return fillInterest.tryRegister(callback);
}
@Override