Created
February 11, 2019 20:24
-
-
Save bjonnh/e561789061e9738776676b7530bd484d 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
fun run(): arrow.core.Tuple2<IO<ResultSet>, () -> kotlin.Unit> { | |
val (localExec, cancelQuery) = fxCancellable { | |
createQueryExecutionInExternalLib(…Some query…) // returns immediately with an object that allows to abort | |
} | |
val (localResult, cancelResult) = fxCancellable { | |
localExec.bind().executequery() // Blocking task | |
} | |
return fx { localResult.bind() } toT { | |
cancelQuery() | |
cancelResult() | |
fx { localExec.bind().abort() }.unsafeRunSync() | |
} // Here I return a function for the cancellable, that allows me to cancel all the tasks (and call the abort on the object for cleanup) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment