-
-
Save kcleereman/f8f11d010f88df5b36ce to your computer and use it in GitHub Desktop.
Creation of CancellableStatement
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
public class Immutable { | |
private final ExecutorService priorityExecutorService; | |
private final ExecutionContext priorityExecutionContext; | |
public Immutable() { | |
this.priorityExecutorService = Executors.newCachedThreadPool(); | |
this.priorityExecutionContext = ExecutionContexts.fromExecutorService(priorityExecutorService); | |
} | |
public CancellableStatement getCancellableStatement(Promise<String> cancellation) { | |
CancellableStatement cancellableStatement = new CancellableStatement(priorityExecutorService, cancellation, listener); | |
cancellation.future().onFailure(new OnFailure() { | |
@Override | |
public void onFailure(Throwable failure) { | |
cancellableStatement.cancel(); | |
} | |
}, priorityExecutionContext); | |
return cancellableStatement; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment