Skip to content

Instantly share code, notes, and snippets.

@lwahlmeier
Created January 30, 2018 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwahlmeier/d2f61da089b364af75edb494277af434 to your computer and use it in GitHub Desktop.
Save lwahlmeier/d2f61da089b364af75edb494277af434 to your computer and use it in GitHub Desktop.
/**
* <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