mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:10:43 +07:00
convert CancellationFutureTask to Kotlin
GitOrigin-RevId: cafa49e06618db3bd79efb41a60be2923c36f804
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a55e9d0ea
commit
ad9fb0700e
@@ -1,28 +1,21 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.concurrency;
|
||||
package com.intellij.util.concurrency
|
||||
|
||||
import kotlinx.coroutines.Job;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import kotlinx.coroutines.Job
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.FutureTask
|
||||
|
||||
/**
|
||||
* A FutureTask, which cancels the given job when it's cancelled.
|
||||
*/
|
||||
final class CancellationFutureTask<V> extends FutureTask<V> {
|
||||
internal class CancellationFutureTask<V>(
|
||||
private val job: Job,
|
||||
callable: Callable<V>,
|
||||
) : FutureTask<V>(callable) {
|
||||
|
||||
private final @NotNull Job myJob;
|
||||
|
||||
CancellationFutureTask(@NotNull Job job, @NotNull Callable<V> callable) {
|
||||
super(callable);
|
||||
myJob = job;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel(boolean mayInterruptIfRunning) {
|
||||
boolean result = super.cancel(mayInterruptIfRunning);
|
||||
myJob.cancel(null);
|
||||
return result;
|
||||
override fun cancel(mayInterruptIfRunning: Boolean): Boolean {
|
||||
val result = super.cancel(mayInterruptIfRunning)
|
||||
job.cancel(null)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user