mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(modules): convert ActionScheduler to Standalone and simplify async execute signature
This commit is contained in:
@@ -29,7 +29,7 @@ import java.time.temporal.ChronoUnit
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
class ActionScheduler : AbstractAgentModule.Sub<Set<Schedulable>, Void?>() {
|
||||
class ActionScheduler : AbstractAgentModule.Standalone() {
|
||||
@InjectCapability
|
||||
private lateinit var actionCapability: ActionCapability
|
||||
|
||||
@@ -79,8 +79,7 @@ class ActionScheduler : AbstractAgentModule.Sub<Set<Schedulable>, Void?>() {
|
||||
})
|
||||
}
|
||||
|
||||
override fun execute(input: Set<Schedulable>): Void? {
|
||||
schedulerScope.launch {
|
||||
fun execute(input: Set<Schedulable>) = schedulerScope.launch {
|
||||
for (schedulableData in input) {
|
||||
log.debug("New data to schedule: {}", schedulableData)
|
||||
timeWheel.schedule(schedulableData)
|
||||
@@ -89,8 +88,6 @@ class ActionScheduler : AbstractAgentModule.Sub<Set<Schedulable>, Void?>() {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private class TimeWheel(
|
||||
val listSource: () -> Set<Schedulable>,
|
||||
|
||||
Reference in New Issue
Block a user