org.enodeframework.common.io.Task.kt Maven / Gradle / Ivy
package org.enodeframework.common.io
import org.enodeframework.common.exception.EnodeInterruptException
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CountDownLatch
/**
* @author [email protected]
*/
object Task {
@JvmField
var completedTask: CompletableFuture = CompletableFuture.completedFuture(true)
@JvmStatic
fun await(latch: CountDownLatch) {
try {
latch.await()
} catch (e: InterruptedException) {
throw EnodeInterruptException(e)
}
}
@JvmStatic
fun await(future: CompletableFuture): T {
return future.join()
}
@JvmStatic
fun sleep(sleepMilliseconds: Long) {
try {
Thread.sleep(sleepMilliseconds)
} catch (e: InterruptedException) {
throw EnodeInterruptException(e)
}
}
}