org.enodeframework.common.io.Task.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode Show documentation
Show all versions of enode Show documentation
The enodeframework core implementation.
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.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)
}
}
}