All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.jakta.agents.fsm.impl.SimulatedTimeRunner.kt Maven / Gradle / Ivy

There is a newer version: 0.11.106
Show newest version
package it.unibo.jakta.agents.fsm.impl

import it.unibo.jakta.agents.fsm.Activity
import it.unibo.jakta.agents.fsm.time.Time
import it.unibo.jakta.agents.utils.Promise

class SimulatedTimeRunner(
    override val activity: Activity,
    private val currentTime: () -> Time,
) : AbstractRunner(activity) {

    override fun onPause() = error("Is not possible to PAUSE a DiscreteTimeRunner")

    override fun onResume() = error("Is not possible to RESUME a DiscreteTimeRunner")

    override fun getCurrentTime(): Time = currentTime()

    override fun run(): Promise {
        val promise = Promise()
        while (!isOver) {
            safeExecute({ promise.completeExceptionally(it) }) {
                doStateTransition()
            }
        }
        promise.complete(null)
        return promise
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy