summaryrefslogtreecommitdiff
path: root/opendc-faas/opendc-faas-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-19 17:27:01 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-25 17:58:54 +0200
commit86c65e875b7dde8872dc81a37aa9dca72eee7782 (patch)
tree6249023f8f0d56392400c7ebb72238ee848f740a /opendc-faas/opendc-faas-simulator
parentba310a3545c9631e1e4ff61a0a1759228ec5cf63 (diff)
refactor(simulator): Support running workloads without coroutines
This change updates the SimMachine interface to drop the coroutine requirement for running a workload on a machines. Users can now asynchronously start a workload and receive notifications via the workload callbacks. Users still have the possibility to suspend execution during workload execution by using the new `runWorkload` method, which is implemented on top of the new `startWorkload` primitive.
Diffstat (limited to 'opendc-faas/opendc-faas-simulator')
-rw-r--r--opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt5
1 files changed, 3 insertions, 2 deletions
diff --git a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt
index 020d75b5..68233c1a 100644
--- a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt
+++ b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt
@@ -36,6 +36,7 @@ import org.opendc.simulator.compute.SimMachine
import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
+import org.opendc.simulator.compute.runWorkload
import org.opendc.simulator.flow.FlowEngine
import java.time.Clock
import java.util.ArrayDeque
@@ -114,7 +115,7 @@ public class SimFunctionDeployer(
override fun close() {
state = FunctionInstanceState.Deleted
stop()
- machine.close()
+ machine.cancel()
}
override fun toString(): String = "FunctionInstance[state=$state]"
@@ -130,7 +131,7 @@ public class SimFunctionDeployer(
launch {
try {
- machine.run(workload)
+ machine.runWorkload(workload)
} finally {
state = FunctionInstanceState.Deleted
}