Skip to content

Commit

Permalink
Improve java interop
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Mar 15, 2021
1 parent 8bf7919 commit 6155391
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package dev.kord.x.lavalink.interop

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.future.future
import java.util.concurrent.CompletableFuture

internal fun <T> CoroutineScope.supply(supplier: suspend CoroutineScope.() -> T) =
async(block = supplier).asCompletableFuture()
future(block = supplier)

internal fun CoroutineScope.run(supplier: suspend CoroutineScope.() -> Unit): CompletableFuture<Void> =
supply(supplier).thenApply { null }

0 comments on commit 6155391

Please sign in to comment.