aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
diff options
context:
space:
mode:
authorpacien2018-02-24 02:37:23 +0100
committerpacien2018-02-24 02:37:23 +0100
commite2f985900c3b07f13c768c803106bdd4d9b94772 (patch)
tree6d1dd2d108547780ffc827880db303643704f2ce /app/src/main/java/org/pacien/tincapp/commands/Executor.kt
parent97407c40660893650a6d37c5d760167e2e4d24c7 (diff)
downloadtincapp-e2f985900c3b07f13c768c803106bdd4d9b94772.tar.gz
Unify unit future typing
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/commands/Executor.kt')
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
index fedd0d2..39c413e 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
@@ -33,12 +33,12 @@ internal object Executor {
33 33
34 private fun read(stream: InputStream) = BufferedReader(InputStreamReader(stream)).readLines() 34 private fun read(stream: InputStream) = BufferedReader(InputStreamReader(stream)).readLines()
35 35
36 fun forkExec(cmd: Command): CompletableFuture<Void> { 36 fun forkExec(cmd: Command): CompletableFuture<Unit> {
37 val pid = forkExec(cmd.asArray()).also { 37 val pid = forkExec(cmd.asArray()).also {
38 if (it == FAILED) throw CommandExecutionException("Could not fork child process.") 38 if (it == FAILED) throw CommandExecutionException("Could not fork child process.")
39 } 39 }
40 40
41 return CompletableFuture.runAsync { 41 return runAsyncTask {
42 when (wait(pid)) { 42 when (wait(pid)) {
43 SUCCESS -> Unit 43 SUCCESS -> Unit
44 FAILED -> throw CommandExecutionException("Process terminated abnormally.") 44 FAILED -> throw CommandExecutionException("Process terminated abnormally.")
@@ -60,6 +60,6 @@ internal object Executor {
60 } 60 }
61 } 61 }
62 62
63 fun runAsyncTask(r: () -> Unit) = CompletableFuture.runAsync(Runnable(r), AsyncTask.THREAD_POOL_EXECUTOR)!! 63 fun runAsyncTask(r: () -> Unit) = CompletableFuture.supplyAsync(Supplier(r), AsyncTask.THREAD_POOL_EXECUTOR)!!
64 fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!! 64 fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!!
65} 65}