aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
diff options
context:
space:
mode:
authorBrady <thatgravyboat@gmail.com>2024-04-30 14:49:15 -0230
committerGitHub <noreply@github.com>2024-04-30 19:19:15 +0200
commit8071da11713602d34cf93413e51da85a2a12530d (patch)
tree6c0f29c529f19d2023d185bda83ed94af4c4f157 /src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
parentab49f89977c19cc8eba7911c073a9d74ede1eadf (diff)
downloadskyhanni-8071da11713602d34cf93413e51da85a2a12530d.tar.gz
skyhanni-8071da11713602d34cf93413e51da85a2a12530d.tar.bz2
skyhanni-8071da11713602d34cf93413e51da85a2a12530d.zip
Improvements: Cleanup RPC (#1570)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
index 0b4c3adc9..eb83bce3a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
@@ -10,8 +10,10 @@ object DelayedRun {
private val tasks = mutableListOf<Pair<() -> Any, SimpleTimeMark>>()
private val futureTasks = ConcurrentLinkedQueue<Pair<() -> Any, SimpleTimeMark>>()
- fun runDelayed(duration: Duration, run: () -> Unit) {
- futureTasks.add(Pair(run, SimpleTimeMark.now() + duration))
+ fun runDelayed(duration: Duration, run: () -> Unit): SimpleTimeMark {
+ val time = SimpleTimeMark.now() + duration
+ futureTasks.add(Pair(run, time))
+ return time
}
/** Runs in the next full Tick so the delay is between 50ms to 100ms**/