diff options
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.kt | 6 |
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 | } |