From 7ba74edcce19fe1e5b29a89d0f021d23aef31628 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Tue, 14 May 2024 10:11:35 +0200 Subject: [PATCH] add doc for SingleAlarm GitOrigin-RevId: 68a35ed4351e01ab44fedf2e0121de4ab6e2196b --- platform/ide-core/src/com/intellij/util/SingleAlarm.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/ide-core/src/com/intellij/util/SingleAlarm.kt b/platform/ide-core/src/com/intellij/util/SingleAlarm.kt index a33d4bcad252..80ef380affdb 100644 --- a/platform/ide-core/src/com/intellij/util/SingleAlarm.kt +++ b/platform/ide-core/src/com/intellij/util/SingleAlarm.kt @@ -10,6 +10,14 @@ import java.util.concurrent.ExecutionException import java.util.concurrent.TimeUnit import java.util.concurrent.TimeoutException +/** + * Allows scheduling a single `Runnable` instance ([task]) to be executed after a specific time interval on a specific thread. + * [request] adds a request if it's not scheduled yet, i.e., it does not delay execution of the request + * [cancelAndRequest] cancels the current request and schedules a new one instead, i.e., it delays execution of the request + * + * Consider using a [kotlinx.coroutines.flow.Flow] with [kotlinx.coroutines.flow.debounce] and [kotlinx.coroutines.flow.sample] instead + */ + class SingleAlarm @JvmOverloads constructor( private val task: Runnable, private val delay: Int,