mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +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 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(
|
||||||
|
|||||||
Reference in New Issue
Block a user