Created
January 30, 2018 23:29
-
-
Save lwahlmeier/d2f61da089b364af75edb494277af434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <p>Whenever a the {@link Reader} Interfaces {@link Reader#onRead(Client)} is called the | |
* {@link #getRead()} should be called from the client.</p> | |
* | |
* @return a {@link ReuseableMergedByteBuffers} of the current read data for this client. | |
*/ | |
public ReuseableMergedByteBuffers getRead() { | |
final SettableListenableFuture<ReuseableMergedByteBuffers> slf = new SettableListenableFuture<>(); | |
this.clientExecutor.submit(()->slf.setResult(this.getInternalRead())); | |
try { | |
return slf.get(); | |
} catch (InterruptedException | ExecutionException e) { | |
throw new RuntimeException("Bad problems!", e); | |
} | |
} | |
private ReuseableMergedByteBuffers getInternalRead() { | |
ReuseableMergedByteBuffers mbb = readBuffers.duplicateAndClean(); | |
if(mbb.remaining() >= maxBufferSize) { | |
se.setClientOperations(this); | |
} | |
return mbb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment