refactor(modules): convert ActionScheduler to Standalone and simplify async execute signature

This commit is contained in:
2026-02-20 17:29:26 +08:00
parent bbace28d7a
commit 87c34cc699

View File

@@ -29,7 +29,7 @@ import java.time.temporal.ChronoUnit
import java.util.stream.Collectors import java.util.stream.Collectors
import kotlin.jvm.optionals.getOrNull import kotlin.jvm.optionals.getOrNull
class ActionScheduler : AbstractAgentModule.Sub<Set<Schedulable>, Void?>() { class ActionScheduler : AbstractAgentModule.Standalone() {
@InjectCapability @InjectCapability
private lateinit var actionCapability: ActionCapability private lateinit var actionCapability: ActionCapability
@@ -79,17 +79,14 @@ class ActionScheduler : AbstractAgentModule.Sub<Set<Schedulable>, Void?>() {
}) })
} }
override fun execute(input: Set<Schedulable>): Void? { fun execute(input: Set<Schedulable>) = schedulerScope.launch {
schedulerScope.launch { for (schedulableData in input) {
for (schedulableData in input) { log.debug("New data to schedule: {}", schedulableData)
log.debug("New data to schedule: {}", schedulableData) timeWheel.schedule(schedulableData)
timeWheel.schedule(schedulableData) if (schedulableData is SchedulableExecutableAction) {
if (schedulableData is SchedulableExecutableAction) { actionCapability.putAction(schedulableData)
actionCapability.putAction(schedulableData)
}
} }
} }
return null
} }
private class TimeWheel( private class TimeWheel(