mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
blockingGet — do not call await if not pending
This commit is contained in:
@@ -182,10 +182,12 @@ open class AsyncPromise<T> : Promise<T>, Getter<T> {
|
||||
}
|
||||
|
||||
override fun blockingGet(timeout: Int, timeUnit: TimeUnit): T? {
|
||||
val latch = CountDownLatch(1)
|
||||
processed { latch.countDown() }
|
||||
if (!latch.await(timeout.toLong(), timeUnit)) {
|
||||
throw TimeoutException()
|
||||
if (isPending) {
|
||||
val latch = CountDownLatch(1)
|
||||
processed { latch.countDown() }
|
||||
if (!latch.await(timeout.toLong(), timeUnit)) {
|
||||
throw TimeoutException()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
Reference in New Issue
Block a user